diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java index b98044e6..aa9b97fe 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java @@ -79,6 +79,8 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity @Shadow protected abstract void sendSneakingPacket(); + @Shadow private boolean lastHorizontalCollision; + @WrapWithCondition(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSneakingPacket()V")) private boolean sendSneakingAfterSprinting(ClientPlayerEntity instance) { return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_21_2); @@ -91,6 +93,16 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity } } + @Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;lastHorizontalCollision:Z", ordinal = 0)) + private boolean removeHorizontalCollisionFromOnGroundCheck(ClientPlayerEntity instance) { + // Since it doesn't exist in older versions, we need to exclude it from the check to prevent bad packets + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) { + return this.horizontalCollision; + } else { + return this.lastHorizontalCollision; + } + } + @WrapWithCondition(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;jump()V")) private boolean dontJumpBeforeFlying(ClientPlayerEntity instance) { return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_20_5);