2525import net.minecraft.block.enums.CameraSubmersionType;
2626import net.minecraft.client.render.Camera;
2727import net.minecraft.entity.Entity;
28- import net.minecraft.world.BlockView;
2928import net.minecraft.world.World;
3029import org.spongepowered.asm.mixin.Mixin;
3130import org.spongepowered.asm.mixin.Shadow;
@@ -42,6 +41,12 @@ public abstract class CameraMixin {
4241 @Shadow
4342 public abstract void setRotation(float yaw, float pitch);
4443
44+ @Shadow
45+ public abstract float getPitch();
46+
47+ @Shadow
48+ public abstract float getYaw();
49+
4550 @Inject(method = "update", at = @At("TAIL"))
4651 private void onUpdate(World area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickProgress, CallbackInfo ci) {
4752 if (!Freecam.INSTANCE.isEnabled()) return;
@@ -59,22 +64,23 @@ private void onUpdate(World area, Entity focusedEntity, boolean thirdPerson, boo
5964 * );
6065 * }</pre>
6166 */
62- @Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD )V", shift = At.Shift.AFTER))
67+ @Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setRotation(FF )V", shift = At.Shift.AFTER))
6368 private void injectQuickPerspectiveSwap(World area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickProgress, CallbackInfo ci) {
6469 var rot = RotationManager.getLockRotation();
6570 if (rot == null) return;
66- setRotation(rot.getYawF(), rot.getPitchF());
71+ if (FreeLook.INSTANCE.isEnabled()) {
72+ if (FreeLook.getEnableYaw()) setRotation(rot.getYawF(), getPitch());
73+ if (FreeLook.getEnablePitch()) setRotation(getYaw(), rot.getPitchF());
74+ } else setRotation(rot.getYawF(), rot.getPitchF());
6775 }
6876
6977 /**
7078 * Allows camera to clip through blocks in third person
7179 */
7280 @Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true)
73- private void onClipToSpace(float desiredCameraDistance , CallbackInfoReturnable<Float> info ) {
81+ private void onClipToSpace(float distance , CallbackInfoReturnable<Float> cir ) {
7482 if (CameraTweaks.INSTANCE.isEnabled() && CameraTweaks.getNoClipCam()) {
75- info.setReturnValue(desiredCameraDistance);
76- } else if (FreeLook.INSTANCE.isEnabled()) {
77- info.setReturnValue(desiredCameraDistance);
83+ cir.setReturnValue(distance);
7884 }
7985 }
8086
@@ -91,14 +97,12 @@ private void onClipToSpace(float desiredCameraDistance, CallbackInfoReturnable<F
9197 * }</pre>
9298 */
9399 @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;clipToSpace(F)F"))
94- private float onDistanceUpdate(float desiredCameraDistance ) {
100+ private float onDistanceUpdate(float distance ) {
95101 if (CameraTweaks.INSTANCE.isEnabled()) {
96102 return CameraTweaks.getCamDistance();
97- } else if (FreeLook.INSTANCE.isEnabled()) {
98- return 4.0F;
99103 }
100104
101- return desiredCameraDistance ;
105+ return distance ;
102106 }
103107
104108 /**
0 commit comments