2022-06-11 10:41:59 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: BillyGalbreath <blake.galbreath@gmail.com>
|
|
|
|
Date: Tue, 8 Dec 2020 20:24:52 -0600
|
|
|
|
Subject: [PATCH] MC-4: Fix item position desync
|
|
|
|
|
|
|
|
This fixes item position desync (MC-4) by running the item coordinates
|
|
|
|
through the encode/decode methods of the packet that causes the precision
|
|
|
|
loss, which forces the server to lose the same precision as the client
|
|
|
|
keeping them in sync.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
2024-04-16 21:44:59 +02:00
|
|
|
index ffec3deb9bcd31d51974c1deda2e76bc8374e5c5..a3d247c93ac1a2d872ff0e3841efc3d7b84fcbc1 100644
|
2022-06-11 10:41:59 +02:00
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
2022-12-07 21:16:54 +01:00
|
|
|
@@ -9,12 +9,12 @@ public class VecDeltaCodec {
|
2022-06-11 10:41:59 +02:00
|
|
|
|
2022-12-07 21:16:54 +01:00
|
|
|
@VisibleForTesting
|
|
|
|
static long encode(double value) {
|
2024-04-12 21:14:06 +02:00
|
|
|
- return Math.round(value * 4096.0);
|
|
|
|
+ return Math.round(value * 4096.0); // Paper - Fix MC-4; diff on change
|
2022-06-11 10:41:59 +02:00
|
|
|
}
|
|
|
|
|
2022-12-07 21:16:54 +01:00
|
|
|
@VisibleForTesting
|
|
|
|
static double decode(long value) {
|
2024-04-16 21:44:59 +02:00
|
|
|
- return (double)value / 4096.0;
|
2024-04-12 21:14:06 +02:00
|
|
|
+ return value / 4096.0; // Paper - Fix MC-4; diff on change
|
2022-06-11 10:41:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Vec3 decode(long x, long y, long z) {
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-06-13 17:45:43 +02:00
|
|
|
index f7964a9ef04d35b5bf46ff18071ef22f53b9a3b5..cac4c1bd5d4ee89e4366b7e11fbf01903e953ed9 100644
|
2022-06-11 10:41:59 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-05-26 21:51:15 +02:00
|
|
|
@@ -4217,6 +4217,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
2023-09-22 22:13:57 +02:00
|
|
|
return;
|
|
|
|
}
|
2024-01-24 15:57:53 +01:00
|
|
|
// Paper end - Block invalid positions and bounding box
|
2024-01-20 12:50:16 +01:00
|
|
|
+ // Paper start - Fix MC-4
|
2022-06-11 10:41:59 +02:00
|
|
|
+ if (this instanceof ItemEntity) {
|
|
|
|
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.fixEntityPositionDesync) {
|
2022-06-11 11:02:09 +02:00
|
|
|
+ // encode/decode from ClientboundMoveEntityPacket
|
2024-04-12 21:14:06 +02:00
|
|
|
+ x = Mth.lfloor(x * 4096.0) * (1 / 4096.0);
|
|
|
|
+ y = Mth.lfloor(y * 4096.0) * (1 / 4096.0);
|
|
|
|
+ z = Mth.lfloor(z * 4096.0) * (1 / 4096.0);
|
2022-06-11 10:41:59 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
2024-01-20 12:50:16 +01:00
|
|
|
+ // Paper end - Fix MC-4
|
2022-06-11 10:41:59 +02:00
|
|
|
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
|
|
|
this.position = new Vec3(x, y, z);
|
|
|
|
int i = Mth.floor(x);
|