38 lines
1.6 KiB
Java
38 lines
1.6 KiB
Java
package com.replaymod.render.mixin;
|
|
|
|
import com.replaymod.pathing.properties.FovProperty;
|
|
import net.minecraft.client.render.GameRenderer;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
|
|
|
@Mixin(GameRenderer.class)
|
|
public abstract class Mixin_DynamicFov {
|
|
private static final String METHOD = "getBasicProjectionMatrix";
|
|
//#if MC>=11903
|
|
//#if MC>=12005
|
|
//$$ private static final String TARGET = "Lorg/joml/Matrix4f;perspective(FFFF)Lorg/joml/Matrix4f;";
|
|
//#else
|
|
//$$ private static final String TARGET = "Lorg/joml/Matrix4f;setPerspective(FFFF)Lorg/joml/Matrix4f;";
|
|
//#endif
|
|
//$$ private static final boolean TARGET_REMAP = false;
|
|
//#else
|
|
private static final String TARGET = "Lnet/minecraft/util/math/Matrix4f;viewboxMatrix(DFFF)Lnet/minecraft/util/math/Matrix4f;";
|
|
private static final boolean TARGET_REMAP = true;
|
|
//#endif
|
|
|
|
@ModifyArg(method = METHOD, at = @At(value = "INVOKE", target = TARGET, remap = TARGET_REMAP), index = 0)
|
|
//#if MC>=11903
|
|
//$$ private float replayModRender_dynamicFov(float fovY) {
|
|
//$$ Float override = FovProperty.currentOverride;
|
|
//$$ if (override == null) return fovY;
|
|
//$$ return (float) Math.toRadians(Math.max(1f, Math.min(179f, override)));
|
|
//$$ }
|
|
//#else
|
|
private double replayModRender_dynamicFov(double fovY) {
|
|
Float override = FovProperty.currentOverride;
|
|
if (override == null) return fovY;
|
|
return Math.max(1.0, Math.min(179.0, override));
|
|
}
|
|
//#endif
|
|
} |