Fix fake players not teleporting to unloaded chunks (#1665)

* fake-players-teleporting-fix:
* Fix fake players not being moved on the chunkmap when teleporting
* Fixes #1190 (Player bots cannot be teleported to unloaded chunks)

* fake-players-teleporting-fix:
* add missing access widener

* Revert "fake-players-teleporting-fix:"

This reverts commit 617702fca14035913103140d2e04fa33065bf628.

* fake-players-teleporting-fix:
* access awaitingTeleport in a nicer way

* fake-players-teleporting-fix: * access awaitingTeleport in a nicer way
This commit is contained in:
James McCulloch authored and GitHub committed 2023-03-14 17:02:41 +01:00
1 parent 40c789b2f9
commit 8c09946bef
3 files changed
+37

No files matched your search

@@ -0,0 +1,11 @@
package carpet.mixins;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ServerGamePacketListenerImpl.class)
public interface ServerGamePacketListenerImplAccessor {
@Accessor("awaitingTeleport")
public int getAwaitingTeleport();
}
@@ -1,11 +1,16 @@
package carpet.patches;
import carpet.mixins.ServerGamePacketListenerImplAccessor;
import net.minecraft.network.Connection;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ServerboundAcceptTeleportationPacket;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.world.entity.RelativeMovement;
import java.util.Set;
public class NetHandlerPlayServerFake extends ServerGamePacketListenerImpl
{
@@ -27,6 +32,26 @@ public class NetHandlerPlayServerFake extends ServerGamePacketListenerImpl
((EntityPlayerMPFake) player).kill(message);
}
}
private boolean hasSpawned = false;
@Override
public void teleport(double d, double e, double f, float g, float h, Set<RelativeMovement> set)
{
super.teleport(d, e, f, g, h, set);
handleAcceptTeleportPacket(
new ServerboundAcceptTeleportationPacket( ((ServerGamePacketListenerImplAccessor)this).getAwaitingTeleport() )
);
if (!hasSpawned) {
hasSpawned = true;
} else {
handleMovePlayer(
new ServerboundMovePlayerPacket.PosRot(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot(), false)
);
}
}
}
+1
View File
@@ -8,6 +8,7 @@
"MobCategory_spawnMixin",
"Commands_customCommandsMixin",
"ServerGamePacketListenerImplMixin",
"ServerGamePacketListenerImplAccessor",
"PerfCommand_permissionMixin",
"FillCommandMixin",