Gimbal/src/main/java/net/moonleay/gimble/mixin/NoClipCameraFixMixin.java

21 lines
825 B
Java

package net.moonleay.gimble.mixin;
import net.minecraft.client.render.Camera;
import net.moonleay.gimble.client.editor.ClientEditor;
import net.moonleay.gimble.editor.state.mode.ModeModifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Camera.class)
public class NoClipCameraFixMixin {
@Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true)
private void fixCameraInNoClip(double desiredCameraDistance, CallbackInfoReturnable<Double> cir) {
if (ClientEditor.INSTANCE.containsModifier(ModeModifier.NO_CLIP)){
cir.setReturnValue(desiredCameraDistance);
cir.cancel();
}
}
}