Readd mc-4 fix
This commit is contained in:
parent
c80df849c2
commit
1ccff4f5d1
|
@ -1,67 +0,0 @@
|
||||||
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.
|
|
||||||
|
|
||||||
1.19: entity tracking position changes
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
||||||
index ccc60a5465efa2b71fc2593d75af62c0b64fe66c..1adbceadd5df96e17796561a40eb7b760493440e 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 78dbc89bb247b2765bd2d7d81013d18dfe35539f..e53d8fe713a4c9920f40bf91d6453d36520b45f7 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
||||||
@@ -3802,6 +3802,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 (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);
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
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
|
||||||
|
index 6b49e66f0e45eb7ed525fe4314d2a9615212f7e4..4f9a5837d66c1940385e94f80d865cde1c4cf2a2 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -3888,6 +3888,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 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);
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Collision option for requiring a player participant
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
index 6b49e66f0e45eb7ed525fe4314d2a9615212f7e4..7634e8a8859f6fbf68cc3f62c698ecb84264f9c0 100644
|
index 4f9a5837d66c1940385e94f80d865cde1c4cf2a2..db6be2d9144fb1da9583833849f7b5518402c26d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
@@ -1714,6 +1714,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -1714,6 +1714,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue