Update the fabric zoom mixin to avoid compatibility issues

This commit is contained in:
Username404 2021-07-15 20:59:52 +02:00
parent f495ff1f4e
commit 56255825e2
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 8 additions and 9 deletions

View File

@ -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<Double> cir) {
if (Zoom.INSTANCE.getToggled()) {
cir.setReturnValue(Zoom.getNewZoom(cir.getReturnValue()));
}
}
}