aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1037-Fix-entity-tracker-desync-when-new-players-are-added.patch
diff options
context:
space:
mode:
authorSpottedleaf <[email protected]>2024-07-11 08:32:15 -0700
committerSpottedleaf <[email protected]>2024-07-11 08:34:10 -0700
commita594d182e49e6f5a788075243bbff97f86b1edd7 (patch)
tree604c10e100dc6ff178a9131ed27023e13ee3e647 /patches/server/1037-Fix-entity-tracker-desync-when-new-players-are-added.patch
parent8b558d9e0b5164dd93421624a3ce5c7f3dfb8fa6 (diff)
downloadPaper-a594d182e49e6f5a788075243bbff97f86b1edd7.tar.gz
Paper-a594d182e49e6f5a788075243bbff97f86b1edd7.zip
Fix entities not being visible to clients when teleporting
When teleporting, the spawn position packet will contain the old position. Then the following tracking update will send a teleport packet, but the client will lerp the position change over 3 ticks. However, the client does not tick entities in unloaded chunks - resulting in the lerp never occuring. We fix this by sending the current position in the spawn packet.
Diffstat (limited to 'patches/server/1037-Fix-entity-tracker-desync-when-new-players-are-added.patch')
-rw-r--r--patches/server/1037-Fix-entity-tracker-desync-when-new-players-are-added.patch27
1 files changed, 27 insertions, 0 deletions
diff --git a/patches/server/1037-Fix-entity-tracker-desync-when-new-players-are-added.patch b/patches/server/1037-Fix-entity-tracker-desync-when-new-players-are-added.patch
index b4b1053293..576b74c10c 100644
--- a/patches/server/1037-Fix-entity-tracker-desync-when-new-players-are-added.patch
+++ b/patches/server/1037-Fix-entity-tracker-desync-when-new-players-are-added.patch
@@ -20,6 +20,33 @@ Resetting the last sent position every time a new player is
added to the tracker is just easier to do, so that is what
this patch does.
+This patch also fixes entities appearing to disappear when
+teleporting to players by changing the initial position
+in the spawn packet to the entities current tracking position.
+When teleporting, the spawn packet will contain the old position
+which is most likely in an unloaded chunk - which means that the
+client will not tick the entity and thus not lerp the entity
+from its old position to its new position.
+
+diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
+index 1a5e73fd97781f3903e5ef13aa0352c64fbc2cc1..4126d82e83810126eb4a41b4587dc993542f3793 100644
+--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
++++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
+@@ -42,9 +42,11 @@ public class ClientboundAddEntityPacket implements Packet<ClientGamePacketListen
+ this(
+ entity.getId(),
+ entity.getUUID(),
+- entityTrackerEntry.getPositionBase().x(),
+- entityTrackerEntry.getPositionBase().y(),
+- entityTrackerEntry.getPositionBase().z(),
++ // Paper start - fix entity tracker desync
++ entity.trackingPosition().x(),
++ entity.trackingPosition().y(),
++ entity.trackingPosition().z(),
++ // Paper end - fix entity tracker desync
+ entityTrackerEntry.getLastSentXRot(),
+ entityTrackerEntry.getLastSentYRot(),
+ entity.getType(),
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index c96740a82eac9101f74edeb44edf4b64d1d633e0..8b6754525fafd1aaac3292cf69a855d6a42b9523 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java