diff options
author | Jake Potrebic <[email protected]> | 2023-11-04 14:11:55 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2023-11-04 14:11:55 -0700 |
commit | 0cdce89d595a2c1c097c9e2a5ff96687977b3b25 (patch) | |
tree | de63d6aa8112811f93b5d6afebbb069b9980870f /patches/server/0507-MC-4-Fix-item-position-desync.patch | |
parent | 15a0de2eefb70ea8162cbb31056920adf80265fa (diff) | |
download | Paper-0cdce89d595a2c1c097c9e2a5ff96687977b3b25.tar.gz Paper-0cdce89d595a2c1c097c9e2a5ff96687977b3b25.zip |
Fix a bunch of stuff with player spawn locations (#9887)
If a playerdata doesn't contain a valid, loaded world, reset
to the main world spawn point
Diffstat (limited to 'patches/server/0507-MC-4-Fix-item-position-desync.patch')
-rw-r--r-- | patches/server/0507-MC-4-Fix-item-position-desync.patch | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/patches/server/0507-MC-4-Fix-item-position-desync.patch b/patches/server/0507-MC-4-Fix-item-position-desync.patch new file mode 100644 index 0000000000..9976e41aba --- /dev/null +++ b/patches/server/0507-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 05ac41e136da43284fb24a6b698ebd36318278fb..33d9131e9c75ef23cd637f5d6c39a2704a0c92a5 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.0D); ++ return Math.round(value * 4096.0D); // Paper - diff on change + } + + @VisibleForTesting + static double decode(long value) { +- return (double)value / 4096.0D; ++ return (double)value / 4096.0D; // Paper - 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 9257855651f7605935ecab121e239bef7218e53c..e8604fa9ef819db8a5f5fabc99022095bce7b00d 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -4227,6 +4227,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + return; + } + // Paper end - rewrite chunk system ++ // 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.0D) * (1 / 4096.0D); ++ y = Mth.lfloor(y * 4096.0D) * (1 / 4096.0D); ++ z = Mth.lfloor(z * 4096.0D) * (1 / 4096.0D); ++ } ++ } ++ // 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); |