From 3fa76e8f477a027e8c3f0f501fa7e4c34e548550 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Mon, 2 Dec 2024 17:06:17 +0100 Subject: [PATCH] Fix wrong item swing injections --- .../fixes/minecraft/MixinMinecraftClient.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinMinecraftClient.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinMinecraftClient.java index 97728f8e..8fd32485 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinMinecraftClient.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinMinecraftClient.java @@ -93,15 +93,19 @@ private boolean disableSwing(ClientPlayerEntity instance, Hand hand) { return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15); } - @WrapWithCondition(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;resetEquipProgress(Lnet/minecraft/util/Hand;)V")) - private boolean disableSwing2(HeldItemRenderer instance, Hand hand) { - return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15); + @Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult$Success;swingSource()Lnet/minecraft/util/ActionResult$SwingSource;", ordinal = 0)) + private ActionResult.SwingSource disableSwing(ActionResult.Success instance) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { + return ActionResult.SwingSource.NONE; + } else { + return instance.swingSource(); + } } - @Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult$Success;swingSource()Lnet/minecraft/util/ActionResult$SwingSource;")) - private ActionResult.SwingSource swingWhenConsume(ActionResult.Success instance) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4) && instance.isAccepted()) { - return ActionResult.SwingSource.CLIENT; + @Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult$Success;swingSource()Lnet/minecraft/util/ActionResult$SwingSource;", ordinal = 2)) + private ActionResult.SwingSource disableSwing2(ActionResult.Success instance) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { + return ActionResult.SwingSource.NONE; } else { return instance.swingSource(); }