diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java index 89508784d..bd2296787 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java @@ -49,6 +49,7 @@ import com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.ParticleRewrit import com.viaversion.viaversion.protocols.v1_21to1_21_2.storage.BundleStateTracker; import com.viaversion.viaversion.protocols.v1_21to1_21_2.storage.ChunkLoadTracker; import com.viaversion.viaversion.protocols.v1_21to1_21_2.storage.EntityTracker1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.storage.GroundFlagTracker; import com.viaversion.viaversion.protocols.v1_21to1_21_2.storage.PlayerPositionStorage; import com.viaversion.viaversion.rewriter.AttributeRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; @@ -234,6 +235,7 @@ public final class Protocol1_21To1_21_2 extends AbstractProtocol { final double x = wrapper.passthrough(Types.DOUBLE); // X @@ -322,7 +324,7 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter { wrapper.passthrough(Types.FLOAT); // Yaw wrapper.passthrough(Types.FLOAT); // Pitch - readOnGround(wrapper); + handleOnGround(wrapper); + }); + protocol.registerServerbound(ServerboundPackets1_21_2.MOVE_PLAYER_STATUS_ONLY, wrapper -> { + final GroundFlagTracker tracker = wrapper.user().get(GroundFlagTracker.class); + final boolean prevOnGround = tracker.onGround(); + final boolean prevHorizontalCollision = tracker.horizontalCollision(); + + handleOnGround(wrapper); + if (prevOnGround == tracker.onGround() && prevHorizontalCollision != tracker.horizontalCollision()) { + // Newer clients will send idle packets even though the on ground state didn't change, ignore them + wrapper.cancel(); + } }); - protocol.registerServerbound(ServerboundPackets1_21_2.MOVE_PLAYER_STATUS_ONLY, this::readOnGround); protocol.registerServerbound(ServerboundPackets1_21_2.ACCEPT_TELEPORTATION, wrapper -> { final PlayerPositionStorage playerPositionStorage = wrapper.user().get(PlayerPositionStorage.class); if (playerPositionStorage.checkHasPlayerPosition()) { @@ -370,9 +382,12 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter. + */ +package com.viaversion.viaversion.protocols.v1_21to1_21_2.storage; + +import com.viaversion.viaversion.api.connection.StorableObject; + +public final class GroundFlagTracker implements StorableObject { + + private boolean onGround; + private boolean horizontalCollision; + + public boolean onGround() { + return this.onGround; + } + + public boolean setOnGround(boolean onGround) { + return this.onGround = onGround; + } + + public boolean horizontalCollision() { + return this.horizontalCollision; + } + + public void setHorizontalCollision(boolean horizontalCollision) { + this.horizontalCollision = horizontalCollision; + } + +}