2022-06-11 08:41:59 +00: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
|
|
|
|
index 3768a71491ef7836b9739bdaec7a077c523dbacd..a57957ace1a72b3308487f180a366c3879eceb21 100644
|
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
|
|
|
@@ -8,11 +8,11 @@ public class VecDeltaCodec {
|
|
|
|
public Vec3 base = Vec3.ZERO; // Paper
|
|
|
|
|
|
|
|
private static long encode(double value) {
|
|
|
|
- return Mth.lfloor(value * 4096.0D);
|
|
|
|
+ return Mth.lfloor(value * 4096.0D); // Paper - check ItemEntity#setPosRaw on update
|
|
|
|
}
|
|
|
|
|
|
|
|
private static double decode(long value) {
|
|
|
|
- return (double)value / 4096.0D;
|
|
|
|
+ return (double)value / 4096.0D; // Paper - check ItemEntity#setPosRaw on update
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2022-09-26 08:02:51 +00:00
|
|
|
index 0e8a5c3fbbafa90f0975733a534aace646e73fde..45931b056abab7c38bc7c6713192be4b62a7e6e4 100644
|
2022-06-11 08:41:59 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2022-09-26 08:02:51 +00:00
|
|
|
@@ -3971,6 +3971,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Paper end - rewrite chunk system
|
2022-06-11 08:41:59 +00:00
|
|
|
+ // Paper start - fix MC-4
|
|
|
|
+ if (this instanceof ItemEntity) {
|
|
|
|
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.fixEntityPositionDesync) {
|
2022-06-11 09:02:09 +00:00
|
|
|
+ // encode/decode from ClientboundMoveEntityPacket
|
2022-06-11 08:41:59 +00:00
|
|
|
+ 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);
|