diff --git a/fabric/src/main/java/fr/username404/snowygui/mixins/ZoomMixin.java b/fabric/src/main/java/fr/username404/snowygui/mixins/ZoomMixin.java index 1d54b01..8cfca69 100644 --- a/fabric/src/main/java/fr/username404/snowygui/mixins/ZoomMixin.java +++ b/fabric/src/main/java/fr/username404/snowygui/mixins/ZoomMixin.java @@ -1,20 +1,19 @@ package fr.username404.snowygui.mixins; import fr.username404.snowygui.gui.feature.Zoom; -import net.minecraft.client.Options; +import net.minecraft.client.Camera; import net.minecraft.client.renderer.GameRenderer; -import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(GameRenderer.class) abstract class ZoomMixin { - @Redirect( - at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;fov:D", opcode = Opcodes.GETFIELD, ordinal = 0), - method = "getFov(Lnet/minecraft/client/Camera;FZ)D" - ) - private double getFov(Options options) { - return Zoom.INSTANCE.getToggled() ? Zoom.getNewZoom(options.fov) : options.fov; + @Inject(at = @At(value = "RETURN"), method = "getFov(Lnet/minecraft/client/Camera;FZ)D", cancellable = true) + private void getFov(Camera camera, float f, boolean bl, CallbackInfoReturnable cir) { + if (Zoom.INSTANCE.getToggled()) { + cir.setReturnValue(Zoom.getNewZoom(cir.getReturnValue())); + } } }