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-01-20 12:50:16 +01:00
|
|
|
index 05ac41e136da43284fb24a6b698ebd36318278fb..3c4ac79c094dc2fff7de94150a34b7bf814ac0de 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) {
|
|
|
|
- return Math.round(value * 4096.0D);
|
2024-01-20 12:50:16 +01:00
|
|
|
+ return Math.round(value * 4096.0D); // 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) {
|
2022-06-11 10:41:59 +02:00
|
|
|
- return (double)value / 4096.0D;
|
2024-01-20 12:50:16 +01:00
|
|
|
+ return (double)value / 4096.0D; // 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
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
index a0c4f6edc87d653bcbe23621bfcf9fbbd20b013d..745e22b78613f8c45f5432fb27e3b9c87cdf2313 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
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -4183,6 +4183,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
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
|
2022-06-11 10:41:59 +02: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);
|
|
|
|
+ }
|
|
|
|
+ }
|
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);
|