From 380693a2b74a9a3686ab1dafdaba7ff6c1a2117f Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 19 Oct 2026 08:56:43 +0200 Subject: [PATCH] Fix REntity position desync and velocity in 1.21 replays Send ClientboundEntityPositionSyncPacket instead of the teleport packet so relative moves keep working afterwards, and pass rotation in degrees. Pass the velocity unscaled to Vec3 instead of pre-multiplying by 8000. Fixes #247 --- .../src/de/steamwar/entity/REntity.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java index 5035e30f..ba849b29 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java @@ -180,7 +180,7 @@ public class REntity { } public void setVelocity(double dX, double dY, double dZ) { - server.updateEntity(this, new ClientboundSetEntityMotionPacket(entityId, new Vec3(calcVelocity(dX), calcVelocity(dY), calcVelocity(dZ)))); + server.updateEntity(this, new ClientboundSetEntityMotionPacket(entityId, new Vec3(dX, dY, dZ))); } public void showDamage() { @@ -340,8 +340,8 @@ public class REntity { } private Object getTeleportPacket() { - PositionMoveRotation rot = new PositionMoveRotation(new Vec3(x, y, z), Vec3.ZERO, pitch, yaw); - return new ClientboundTeleportEntityPacket(entityId, rot, Collections.emptySet(), false); + PositionMoveRotation rot = new PositionMoveRotation(new Vec3(x, y, z), Vec3.ZERO, pitch * 360F / 256F, yaw * 360F / 256F); + return new ClientboundEntityPositionSyncPacket(entityId, rot, false); } private Object getMoveLookPacket(double diffX, double diffY, double diffZ, boolean rotEq) { @@ -387,10 +387,6 @@ public class REntity { return (byte) ((int) (rot * 256.0F / 360.0F)); } - private int calcVelocity(double value) { - return (int) (Math.max(-3.9, Math.min(value, 3.9)) * 8000); - } - private static Optional formatDisplayName(String displayName) { return displayName != null ? Optional.of(MutableComponent.create(PlainTextContents.create(displayName))) : Optional.empty(); }