From 3b34d6349b3e27674c73aa1d252707877abda8f0 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Sun, 27 Oct 2024 16:17:38 +0100 Subject: [PATCH] Fix sprinting<->sneaking packet order in <= 1.21.1 --- .../minecraft/entity/MixinClientPlayerEntity.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 143c2be1..b98044e6 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 @@ -77,6 +77,20 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity @Shadow private boolean inSneakingPose; + @Shadow protected abstract void sendSneakingPacket(); + + @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); + } + + @Inject(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSprintingPacket()V")) + private void sendSneakingAfterSprinting(CallbackInfo ci) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) { + this.sendSneakingPacket(); + } + } + @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);