mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
2f31569807
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: 9115281f SPIGOT-6832: Improve Player#getPing docs CraftBukkit Changes: fd3478bc7 #967: Store last lava contact location for events Spigot Changes: dbf49382 Rebuild patches 58cb9d26 #113: Use simulationDistance for entity activation range base
66 lines
3.6 KiB
Diff
66 lines
3.6 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/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
index f20497eb1202e3e4c256f6cf04f8644a2413fe27..d48c8e3408510cacc148e8071af95994610869a6 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -101,6 +101,11 @@ public class PaperConfig {
|
|
trackPluginScoreboards = getBoolean("settings.track-plugin-scoreboards", false);
|
|
}
|
|
|
|
+ public static boolean fixEntityPositionDesync = true;
|
|
+ private static void fixEntityPositionDesync() {
|
|
+ fixEntityPositionDesync = getBoolean("settings.fix-entity-position-desync", fixEntityPositionDesync);
|
|
+ }
|
|
+
|
|
public static void registerCommands() {
|
|
for (Map.Entry<String, Command> entry : commands.entrySet()) {
|
|
MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Paper", entry.getValue());
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundMoveEntityPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundMoveEntityPacket.java
|
|
index b30c08bfb8c55161543a4ef09f2e462e0a1fe4ae..ec93f5300cc7d423ec0d292f0f8443f900d72dab 100644
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundMoveEntityPacket.java
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundMoveEntityPacket.java
|
|
@@ -21,11 +21,11 @@ public abstract class ClientboundMoveEntityPacket implements Packet<ClientGamePa
|
|
protected final boolean hasPos;
|
|
|
|
public static long entityToPacket(double coord) {
|
|
- return Mth.lfloor(coord * 4096.0D);
|
|
+ return Mth.lfloor(coord * 4096.0D); // Paper - check ItemEntity#setPosRaw on update
|
|
}
|
|
|
|
public static double packetToEntity(long coord) {
|
|
- return (double)coord / 4096.0D;
|
|
+ return (double)coord / 4096.0D; // Paper - check ItemEntity#setPosRaw on update
|
|
}
|
|
|
|
public Vec3 updateEntityPosition(Vec3 orig) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 8554a0098ad59c69877fa4180df19c97b6cf9a1a..1f43c7bd5d711c2e5a7ff67b3b399b408e950b59 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -3790,6 +3790,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
|
}
|
|
public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
|
|
// Paper end
|
|
+ // Paper start - fix MC-4
|
|
+ if (this instanceof ItemEntity) {
|
|
+ if (com.destroystokyo.paper.PaperConfig.fixEntityPositionDesync) {
|
|
+ // encode/decode from PacketPlayOutEntity
|
|
+ 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);
|