mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 20:30:28 +01:00
51 lines
2.5 KiB
Diff
51 lines
2.5 KiB
Diff
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 20baca3c790799590fcd0e9603cfc89c8b8f7ae4..a9af0cbf5232b57e5f455db7f938d225226210a3 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 b8c41d759858fcb7b5db48351f352deac7796634..37906167da097b6a6308e8c358d6a344c605d550 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -4147,6 +4147,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
}
|
|
public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
|
|
// Paper end
|
|
+ // 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);
|