@@ -47,6 +47,12 @@ public abstract class CameraMixin {
4747 @ Shadow
4848 public abstract float getYaw ();
4949
50+ @ Shadow
51+ public float yaw ;
52+
53+ @ Shadow
54+ public float pitch ;
55+
5056 @ Inject (method = "update" , at = @ At ("TAIL" ))
5157 private void onUpdate (World area , Entity focusedEntity , boolean thirdPerson , boolean inverseView , float tickProgress , CallbackInfo ci ) {
5258 if (!Freecam .INSTANCE .isEnabled ()) return ;
@@ -64,18 +70,21 @@ private void onUpdate(World area, Entity focusedEntity, boolean thirdPerson, boo
6470 * );
6571 * }</pre>
6672 */
67- @ Inject (method = "update" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/render/Camera;setRotation(FF )V" , shift = At .Shift .AFTER ))
73+ @ Inject (method = "update" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/render/Camera;setPos(DDD )V" , shift = At .Shift .AFTER ))
6874 private void injectQuickPerspectiveSwap (World area , Entity focusedEntity , boolean thirdPerson , boolean inverseView , float tickProgress , CallbackInfo ci ) {
6975 var rot = RotationManager .getLockRotation ();
7076 if (rot == null ) return ;
7177 if (FreeLook .INSTANCE .isEnabled ()) {
72- if (FreeLook .getEnableYaw ()) setRotation (rot .getYawF (), getPitch ());
73- if (FreeLook .getEnablePitch ()) setRotation (getYaw (), rot .getPitchF ());
78+ var newYaw = yaw ;
79+ var newPitch = pitch ;
80+ if (FreeLook .getEnableYaw ()) newYaw = rot .getYawF ();
81+ if (FreeLook .getEnablePitch ()) newPitch = rot .getPitchF ();
82+ setRotation (newYaw , newPitch );
7483 } else setRotation (rot .getYawF (), rot .getPitchF ());
7584 }
7685
7786 /**
78- * Allows camera to clip through blocks in third person
87+ * Allows the camera to clip through blocks in third person
7988 */
8089 @ Inject (method = "clipToSpace" , at = @ At ("HEAD" ), cancellable = true )
8190 private void onClipToSpace (float distance , CallbackInfoReturnable <Float > cir ) {
0 commit comments