Move patches around
This commit is contained in:
84
patches/server-remapped/MC-4-Fix-item-position-desync.patch
Normal file
84
patches/server-remapped/MC-4-Fix-item-position-desync.patch
Normal file
@@ -0,0 +1,84 @@
|
||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -0,0 +0,0 @@ public class PaperConfig {
|
||||
private static void trackPluginScoreboards() {
|
||||
trackPluginScoreboards = getBoolean("settings.track-plugin-scoreboards", false);
|
||||
}
|
||||
+
|
||||
+ public static boolean fixEntityPositionDesync = true;
|
||||
+ private static void fixEntityPositionDesync() {
|
||||
+ fixEntityPositionDesync = getBoolean("settings.fix-entity-position-desync", fixEntityPositionDesync);
|
||||
+ }
|
||||
}
|
||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundMoveEntityPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundMoveEntityPacket.java
|
||||
@@ -0,0 +0,0 @@ public class ClientboundMoveEntityPacket implements Packet<ClientGamePacketListe
|
||||
protected boolean hasPos;
|
||||
|
||||
public static long entityToPacket(double coord) {
|
||||
- return Mth.lfloor(coord * 4096.0D);
|
||||
+ return Mth.lfloor(coord * 4096.0D); // Paper - check EntityItem#setPositionRaw on update
|
||||
}
|
||||
|
||||
public static Vec3 packetToEntity(long x, long y, long z) {
|
||||
- return (new Vec3((double) x, (double) y, (double) z)).scale(2.44140625E-4D);
|
||||
+ return (new Vec3((double) x, (double) y, (double) z)).scale(2.44140625E-4D); // Paper - check EntityItem#setPositionRaw on update
|
||||
}
|
||||
|
||||
public ClientboundMoveEntityPacket() {}
|
||||
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/util/Mth.java
|
||||
+++ b/src/main/java/net/minecraft/util/Mth.java
|
||||
@@ -0,0 +0,0 @@ import net.minecraft.core.Vec3i;
|
||||
public class Mth {
|
||||
|
||||
public static final float SQRT_OF_TWO = sqrt(2.0F);
|
||||
- private static final float[] SIN = (float[]) Util.make((Object) (new float[65536]), (afloat) -> {
|
||||
+ private static final float[] SIN = (float[]) Util.make((new float[65536]), (afloat) -> { // Paper - decompile error
|
||||
for (int i = 0; i < afloat.length; ++i) {
|
||||
afloat[i] = (float) Math.sin((double) i * 3.141592653589793D * 2.0D / 65536.0D);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class Mth {
|
||||
return d0 < (double) i ? i - 1 : i;
|
||||
}
|
||||
|
||||
+ public static long floorLong(double d0) { return lfloor(d0); } // Paper - OBFHELPER
|
||||
public static long lfloor(double d0) {
|
||||
long i = (long) d0;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -0,0 +0,0 @@ public class ItemEntity extends Entity {
|
||||
public Packet<?> getAddEntityPacket() {
|
||||
return new ClientboundAddEntityPacket(this);
|
||||
}
|
||||
+
|
||||
+ // Paper start - fix MC-4
|
||||
+ public void setPosRaw(double x, double y, double z) {
|
||||
+ if (com.destroystokyo.paper.PaperConfig.fixEntityPositionDesync) {
|
||||
+ // encode/decode from PacketPlayOutEntity
|
||||
+ x = Mth.floorLong(x * 4096.0D) * (1 / 4096.0D);
|
||||
+ y = Mth.floorLong(y * 4096.0D) * (1 / 4096.0D);
|
||||
+ z = Mth.floorLong(z * 4096.0D) * (1 / 4096.0D);
|
||||
+ }
|
||||
+ super.setPosRaw(x, y, z);
|
||||
+ }
|
||||
+ // Paper end - fix MC-4
|
||||
}
|
||||
Reference in New Issue
Block a user