Update the fabric zoom mixin to avoid compatibility issues
This commit is contained in:
parent
f495ff1f4e
commit
56255825e2
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue