mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Readd mc-4 fix
This commit is contained in:
parent
1762939321
commit
624ed50aa0
3 changed files with 53 additions and 4 deletions
|
@ -194,8 +194,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
public void setDeltaMovement(double x, double y, double z) {
|
public void setDeltaMovement(double x, double y, double z) {
|
||||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
|
}
|
||||||
// Paper end
|
// Paper end - fix MC-4
|
||||||
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
||||||
+ synchronized (this.posLock) { // Paper
|
+ synchronized (this.posLock) { // Paper
|
||||||
this.position = new Vec3(x, y, z);
|
this.position = new Vec3(x, y, z);
|
||||||
|
|
|
@ -41,5 +41,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - block invalid positions
|
+ // Paper end - block invalid positions
|
||||||
// Paper end
|
// Paper end
|
||||||
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
// Paper start - fix MC-4
|
||||||
synchronized (this.posLock) { // Paper
|
if (this instanceof ItemEntity) {
|
||||||
|
|
49
patches/server/MC-4-Fix-item-position-desync.patch
Normal file
49
patches/server/MC-4-Fix-item-position-desync.patch
Normal file
|
@ -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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
|
||||||
|
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -0,0 +0,0 @@ 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);
|
Loading…
Reference in a new issue