mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-26 09:42:06 -07:00
Don't mutate the position of Items for MC-4 Fix (#12702)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
||||
+++ b/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
||||
@@ -5,16 +_,16 @@
|
||||
@@ -5,7 +_,7 @@
|
||||
|
||||
public class VecDeltaCodec {
|
||||
private static final double TRUNCATION_STEPS = 4096.0;
|
||||
@@ -9,14 +9,3 @@
|
||||
|
||||
@VisibleForTesting
|
||||
static long encode(double value) {
|
||||
- return Math.round(value * 4096.0);
|
||||
+ return Math.round(value * 4096.0); // Paper - Fix MC-4; diff on change
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static double decode(long value) {
|
||||
- return value / 4096.0;
|
||||
+ return value / 4096.0; // Paper - Fix MC-4; diff on change
|
||||
}
|
||||
|
||||
public Vec3 decode(long x, long y, long z) {
|
||||
|
@@ -1786,7 +1786,7 @@
|
||||
}
|
||||
|
||||
public void addDeltaMovement(Vec3 addend) {
|
||||
@@ -3661,9 +_,45 @@
|
||||
@@ -3661,9 +_,35 @@
|
||||
return this.getZ((2.0 * this.random.nextDouble() - 1.0) * scale);
|
||||
}
|
||||
|
||||
@@ -1815,16 +1815,6 @@
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Block invalid positions and bounding box
|
||||
+ // Paper start - Fix MC-4
|
||||
+ if (this instanceof ItemEntity) {
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.fixEntityPositionDesync) {
|
||||
+ // encode/decode from VecDeltaCodec todo computation changed?
|
||||
+ x = Mth.lfloor(x * 4096.0) * (1 / 4096.0);
|
||||
+ y = Mth.lfloor(y * 4096.0) * (1 / 4096.0);
|
||||
+ z = Mth.lfloor(z * 4096.0) * (1 / 4096.0);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - Fix MC-4
|
||||
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
||||
+ synchronized (this.posLock) { // Paper - detailed watchdog information
|
||||
this.position = new Vec3(x, y, z);
|
||||
|
@@ -24,6 +24,21 @@
|
||||
}
|
||||
|
||||
public ItemEntity(Level level, double posX, double posY, double posZ, ItemStack itemStack, double deltaX, double deltaY, double deltaZ) {
|
||||
@@ -79,6 +_,14 @@
|
||||
this.bobOffs = other.bobOffs;
|
||||
}
|
||||
|
||||
+ // Paper start - Require item entities to send their location precisely (Fixes MC-4)
|
||||
+ {
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.sendFullPosForItemEntities) {
|
||||
+ this.setRequiresPrecisePosition(true);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - Require item entities to send their location precisely (Fixes MC-4)
|
||||
+
|
||||
@Override
|
||||
public boolean dampensVibrations() {
|
||||
return this.getItem().is(ItemTags.DAMPENS_VIBRATIONS);
|
||||
@@ -116,7 +_,7 @@
|
||||
@Override
|
||||
public void tick() {
|
||||
|
@@ -343,7 +343,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
}
|
||||
}
|
||||
public int maxJoinsPerTick = 5;
|
||||
public boolean fixEntityPositionDesync = true;
|
||||
public boolean sendFullPosForItemEntities = false;
|
||||
public boolean loadPermissionsYmlBeforePlugins = true;
|
||||
@Constraints.Min(4)
|
||||
public int regionFileCacheSize = 256;
|
||||
|
@@ -82,6 +82,7 @@ interface RemovedConfigurations {
|
||||
path("unsupported-settings", "allow-grindstone-overstacking"),
|
||||
path("unsupported-settings", "allow-tripwire-disarming-exploits"),
|
||||
path("commands", "fix-target-selector-tag-completion"),
|
||||
path("misc", "fix-entity-position-desync")
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user