d1a72eac31
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 1fc1020a PR-1049: Add MenuType API 8ae2e3be PR-1055: Expand riptiding API cac68bfb SPIGOT-7890: AttributeModifier#getUniqueId() doesn't match the UUID passed to its constructor 7004fcf2 SPIGOT-7886: Fix mistake in AttributeModifier UUID shim 1ac7f950 PR-1054: Add FireworkMeta#hasPower 4cfb565f SPIGOT-7873: Add powered state for skulls CraftBukkit Changes: bbb30e7a8 SPIGOT-7894: NPE when sending tile entity update ba21e9472 SPIGOT-7895: PlayerItemBreakEvent not firing 0fb24bbe0 SPIGOT-7875: Fix PlayerItemConsumeEvent cancellation causing client-side desync 815066449 SPIGOT-7891: Can't remove second ingredient of MerchantRecipe 45c206f2c PR-1458: Add MenuType API 19c8ef9ae SPIGOT-7867: Merchant instanceof AbstractVillager always returns false 4e006d28f PR-1468: Expand riptiding API bd8aded7d Ignore checks in CraftPlayerProfile for ResolvableProfile used in profile components 8679620b5 SPIGOT-7889: Fix tool component deserialisation without speed and/or correct-for-drops 8d5222691 SPIGOT-7882, PR-1467: Fix conversion of name in Profile Component to empty if it is missing 63f91669a SPIGOT-7887: Remove duplicate ProjectileHitEvent for fireballs 7070de8c8 SPIGOT-7878: Server#getLootTable does not return null on invalid loot table 060ee6cae SPIGOT-7876: Can't kick player or disconnect player in PlayerLoginEvent when checking for cookies 7ccb86cc0 PR-1465: Add FireworkMeta#hasPower 804ad6491 SPIGOT-7873: Add powered state for skulls f9610cdcb Improve minecart movement Spigot Changes: a759b629 Rebuild patches Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
106 Zeilen
6.0 KiB
Diff
106 Zeilen
6.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Tue, 20 Feb 2024 18:24:16 -0800
|
|
Subject: [PATCH] Fix entity tracker desync when new players are added to the
|
|
tracker
|
|
|
|
The delta position packet instructs the client to update
|
|
the entity position by a position difference. However, this position
|
|
difference is relative to the last position in the entity tracker
|
|
state, not the last position which has been sent to the player. As
|
|
a result, if the last position the player has recorded is different
|
|
than the one stored in the entity tracker (which occurs when a new
|
|
player is added to an existing entity tracker state) then the sent
|
|
position difference will cause a position desync for the client.
|
|
|
|
We can resolve this problem by either tracking the last position
|
|
sent per-player, or by simply resetting the last sent position
|
|
in the entity tracker state every time a new player is added.
|
|
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 854baa554da2215a656f976ae2973341c3b2d61c..792b9a72a610cc512a8920d61013b6ba02f71e47 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 21370ed6c7d98d3f3546f0365ac50e5c26ba3bde..af8cb316ac169aa8d98a88765b85bb013b9ba961 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
@@ -1269,6 +1269,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
this.serverEntity.addPairing(player);
|
|
}
|
|
// Paper end - entity tracking events
|
|
+ this.serverEntity.onPlayerAdd(); // Paper - fix desync when a player is added to the tracker
|
|
}
|
|
} else if (this.seenBy.remove(player.connection)) {
|
|
this.serverEntity.removePairing(player);
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
index 12d86f27d04bffed8c3844e36b42fbc2f84dacff..8ea2f24695f5dad55e21f238b69442513e7a90c6 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
@@ -96,6 +96,13 @@ public class ServerEntity {
|
|
this.trackedDataValues = entity.getEntityData().getNonDefaultValues();
|
|
}
|
|
|
|
+ // Paper start - fix desync when a player is added to the tracker
|
|
+ private boolean forceStateResync;
|
|
+ public void onPlayerAdd() {
|
|
+ this.forceStateResync = true;
|
|
+ }
|
|
+ // Paper end - fix desync when a player is added to the tracker
|
|
+
|
|
public void sendChanges() {
|
|
// Paper start - optimise collisions
|
|
if (((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)this.entity).moonrise$isHardColliding()) {
|
|
@@ -145,7 +152,7 @@ public class ServerEntity {
|
|
}
|
|
}
|
|
|
|
- if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) {
|
|
+ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker
|
|
int i;
|
|
int j;
|
|
|
|
@@ -185,7 +192,7 @@ public class ServerEntity {
|
|
long i1 = this.positionCodec.encodeZ(vec3d);
|
|
boolean flag6 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
|
|
|
|
- if (!flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) {
|
|
+ if (!this.forceStateResync && !flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) { // Paper - fix desync when a player is added to the tracker
|
|
if ((!flag2 || !flag3) && !(this.entity instanceof AbstractArrow)) {
|
|
if (flag2) {
|
|
packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) k), (short) ((int) l), (short) ((int) i1), this.entity.onGround());
|
|
@@ -249,6 +256,7 @@ public class ServerEntity {
|
|
}
|
|
|
|
this.entity.hasImpulse = false;
|
|
+ this.forceStateResync = false; // Paper - fix desync when a player is added to the tracker
|
|
}
|
|
|
|
++this.tickCount;
|