From 583139e18e3a02dc694d2a8b2a70d210b6285d70 Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Fri, 29 Nov 2024 13:23:57 -0300 Subject: [PATCH] Fix Tweakeroo's free camera tweak breaking zoom mods (#75) --- .../tweakeroo/mixin/MixinGameRenderer.java | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java index 8b5b5d690..90096d95e 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java @@ -1,14 +1,15 @@ package fi.dy.masa.tweakeroo.mixin; import java.util.function.Predicate; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import net.minecraft.block.enums.CameraSubmersionType; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.At.Shift; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -51,10 +52,36 @@ private void applyZoom(Camera camera, float partialTicks, boolean useFOVSetting, { cir.setReturnValue(Configs.Generic.ZOOM_FOV.getDoubleValue()); } - else if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) + } + + @ModifyExpressionValue(method = "getFov", at = @At(value = "CONSTANT", args = "floatValue=70.0")) + private float applyFreeCameraFov(float original) + { + if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) + { + return ((float) this.client.options.getFov().getValue()); + } + + return original; + } + + @ModifyVariable(method = "getFov", at = @At(value = "LOAD", ordinal = 0), argsOnly = true) + private boolean freezeFovOnFreeCamera(boolean value) + { + return !FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue() && value; + } + + @ModifyExpressionValue( + method = "getFov", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/render/Camera;getSubmersionType()Lnet/minecraft/block/enums/CameraSubmersionType;")) + private CameraSubmersionType ignoreSubmersionTypeOnFreeCamera(CameraSubmersionType original) + { + if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue()) { - cir.setReturnValue((double) this.client.options.getFov().getValue()); + return CameraSubmersionType.NONE; } + + return original; } @Redirect(method = "updateCrosshairTarget", at = @At(value = "INVOKE",