Skip to content

Commit 501370c

Browse files
committed
Fix potential 1.7 teleport confirmation desync
1 parent f2e2f18 commit 501370c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/rewriter/PlayerPacketRewriter1_9.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,12 @@ public void register() {
334334
final PlayerPositionTracker storage = wrapper.user().get(PlayerPositionTracker.class);
335335
storage.sendAnimations();
336336
if (storage.getConfirmId() != -1) {
337-
if (storage.getPosX() == x && storage.getPosY() == y && storage.getPosZ() == z && storage.getYaw() == yaw && storage.getPitch() == pitch) {
337+
// 1.7 uses resynced hitbox minY for y however this can have small floating point error due to the calculations it does to get there on teleport confirm
338+
// This Y error gets propagated from 1.7 to 1.8 to 1.9 which causes teleport confirmation to not properly be detected
339+
// This fixes it similarly to how anticheats detect teleports: https://github.com/GrimAnticheat/Grim/blob/67aa3a9483a9b2a6987d594092697b4104c781f0/common/src/main/java/ac/grim/grimac/manager/SetbackTeleportUtil.java#L315
340+
boolean closeEnoughY = Math.abs(storage.getPosY() - y) <= 1e-7;
341+
342+
if (storage.getPosX() == x && closeEnoughY && storage.getPosZ() == z && storage.getYaw() == yaw && storage.getPitch() == pitch) {
338343
final PacketWrapper confirmTeleport = PacketWrapper.create(ServerboundPackets1_9.ACCEPT_TELEPORTATION, wrapper.user());
339344
confirmTeleport.write(Types.VAR_INT, storage.getConfirmId());
340345
confirmTeleport.sendToServer(Protocol1_9To1_8.class);

0 commit comments

Comments
 (0)