aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0452-MC-4-Fix-item-position-desync.patch
diff options
context:
space:
mode:
authorSpottedleaf <[email protected]>2024-07-17 10:24:53 -0700
committerSpottedleaf <[email protected]>2024-07-17 10:28:32 -0700
commit00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6 (patch)
tree82639515bc5e9ae00c1e639e72137ed51e1ac688 /patches/server/0452-MC-4-Fix-item-position-desync.patch
parent967f98aa81da851740aeb429778e46159fd188df (diff)
downloadPaper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.tar.gz
Paper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.zip
Remove Moonrise utils to MCUtils, remove duplicated/unused utils
Diffstat (limited to 'patches/server/0452-MC-4-Fix-item-position-desync.patch')
-rw-r--r--patches/server/0452-MC-4-Fix-item-position-desync.patch50
1 files changed, 50 insertions, 0 deletions
diff --git a/patches/server/0452-MC-4-Fix-item-position-desync.patch b/patches/server/0452-MC-4-Fix-item-position-desync.patch
new file mode 100644
index 0000000000..c549036daa
--- /dev/null
+++ b/patches/server/0452-MC-4-Fix-item-position-desync.patch
@@ -0,0 +1,50 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: BillyGalbreath <[email protected]>
+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
+index 488ebd443903af812913437f1ade3002093f2470..a043ac10834562d357ef0b5aded2e916e2a0d056 100644
+--- a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
++++ b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
+@@ -9,12 +9,12 @@ public class VecDeltaCodec {
+
+ @VisibleForTesting
+ static long encode(double value) {
+- return Math.round(value * 4096.0);
++ return Math.round(value * 4096.0); // Paper - Fix MC-4; diff on change
+ }
+
+ @VisibleForTesting
+ static double decode(long value) {
+- return (double)value / 4096.0;
++ return value / 4096.0; // Paper - Fix MC-4; diff on change
+ }
+
+ 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
+index 7b4c877d6c613e1c40618bc95a65672ec7a31deb..a99bd882a9fbf4a54a82dbde7086c715ff3e46ea 100644
+--- a/src/main/java/net/minecraft/world/entity/Entity.java
++++ b/src/main/java/net/minecraft/world/entity/Entity.java
+@@ -4261,6 +4261,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
+ return;
+ }
+ // Paper end - Block invalid positions and bounding box
++ // Paper start - Fix MC-4
++ if (this instanceof ItemEntity) {
++ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.fixEntityPositionDesync) {
++ // encode/decode from ClientboundMoveEntityPacket
++ 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);
++ }
++ }
++ // Paper end - Fix MC-4
+ 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);