Skip to content

Commit

Permalink
Fix Tweakeroo's free camera tweak breaking zoom mods (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
EnnuiL authored and sakura-ryoko committed Nov 29, 2024
1 parent a66e9e3 commit 7f4b4d6
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions src/main/java/fi/dy/masa/tweakeroo/mixin/MixinGameRenderer.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 7f4b4d6

Please sign in to comment.