From c848cbd868f371b6718030d44ee075dff16a5699 Mon Sep 17 00:00:00 2001 From: Nolij Date: Sun, 18 Aug 2024 18:50:24 -0400 Subject: [PATCH] fix 24w33a compat --- CHANGELOG.md | 2 +- .../zume/mixin/modern/GameRendererMixin.java | 15 ++++++++++++++- .../zume/mixin/modern/MouseHandlerMixin.java | 16 +++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf4c690e..3384c4fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,2 @@ -- fix NeoForge 21.0.112-beta support +- fix 24w33a - further improvements to overall system stability and other minor adjustments have been made to enhance the user experience diff --git a/modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java index eb1eef19..b36071a7 100644 --- a/modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java @@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Group; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -18,7 +19,8 @@ public abstract class GameRendererMixin { Zume.renderHook(); } - @ModifyReturnValue(method = "getFov", at = @At("TAIL")) + @Group(name = "zume$getFov", min = 1, max = 1) + @ModifyReturnValue(method = "getFov", at = @At("TAIL"), require = 0) public double zume$getFov$TAIL(double original) { if (Zume.isFOVHookActive()) return Zume.fovHook(original); @@ -26,4 +28,15 @@ public abstract class GameRendererMixin { return original; } + // 24w33a (21.2)+ compat + @Dynamic + @Group(name = "zume$getFov", min = 1, max = 1) + @ModifyReturnValue(method = "method_3196(Lnet/minecraft/class_4184;FZ)F", at = @At("TAIL"), require = 0) + public float zume$getFov$TAIL(float original) { + if (Zume.isFOVHookActive()) + return (float) Zume.fovHook(original); + + return original; + } + } diff --git a/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java index ea000aad..c851a8bb 100644 --- a/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java @@ -2,6 +2,8 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import dev.nolij.zume.impl.Zume; import net.minecraft.client.MouseHandler; import net.minecraft.world.entity.player.Inventory; @@ -48,9 +50,21 @@ public abstract class MouseHandlerMixin { return original; } - @WrapWithCondition(method = "onScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Inventory;swapPaint(D)V")) + @Group(name = "zume$onScroll", min = 1, max = 1) + @WrapWithCondition(method = "onScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Inventory;swapPaint(D)V"), require = 0) public boolean onMouseScroll$scrollInHotbar(Inventory instance, double scrollAmount) { return !Zume.mouseScrollHook((int) scrollAmount); } + // 24w33a (21.2)+ compat + @Dynamic + @Group(name = "zume$onScroll", min = 1, max = 1) + @WrapOperation(method = "onScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/class_9928;method_61972(DII)I"), require = 0) + public int zume$onScroll$getNextScrollWheelSelection(double scrollAmount, int current, int max, Operation original) { + if (Zume.mouseScrollHook((int) scrollAmount)) + return current; + + return original.call(scrollAmount, current, max); + } + }