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 99f43f270..8b5e262f4 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java @@ -1,15 +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.Unique; -import org.spongepowered.asm.mixin.injection.At; +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 +51,36 @@ private void applyZoom(Camera camera, float tickDelta, boolean changingFov, Call { cir.setReturnValue((float) 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((float) this.client.options.getFov().getValue()); + return CameraSubmersionType.NONE; } + + return original; } @Redirect(method = "updateCrosshairTarget", at = @At(value = "INVOKE",