Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Tweakeroo's free camera tweak breaking zoom mods #75

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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