Fix wrong item swing injections

This commit is contained in:
FlorianMichael 2024-12-02 17:06:17 +01:00
parent 5d51aefccc
commit 3fa76e8f47
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126

View File

@ -93,15 +93,19 @@ public abstract class MixinMinecraftClient {
return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15); 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")) @Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult$Success;swingSource()Lnet/minecraft/util/ActionResult$SwingSource;", ordinal = 0))
private boolean disableSwing2(HeldItemRenderer instance, Hand hand) { private ActionResult.SwingSource disableSwing(ActionResult.Success instance) {
return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15); 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;")) @Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult$Success;swingSource()Lnet/minecraft/util/ActionResult$SwingSource;", ordinal = 2))
private ActionResult.SwingSource swingWhenConsume(ActionResult.Success instance) { private ActionResult.SwingSource disableSwing2(ActionResult.Success instance) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4) && instance.isAccepted()) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
return ActionResult.SwingSource.CLIENT; return ActionResult.SwingSource.NONE;
} else { } else {
return instance.swingSource(); return instance.swingSource();
} }