Skip to content

Commit

Permalink
Fix: incorrect roll on certain axis
Browse files Browse the repository at this point in the history
  • Loading branch information
der-fruhling committed Apr 22, 2024
1 parent 47bfe66 commit 4e0d971
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ public interface PlayerPerspectiveBehavior {
void setLean(float lean);
void setYaw(float yaw);
float getLean();
float getYaw();
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public void modifyRotationsPrimary(Camera instance, float y, float x) {
if(entity instanceof LocalPlayer player) {
var persp = (PlayerPerspectiveBehavior) Minecraft.getInstance().getEntityRenderDispatcher().getRenderer(player);
ctp$setRotation3D(y,
x + persp.getLean() * Mth.cos(y * Mth.DEG_TO_RAD),
360.0f - (persp.getLean() * Mth.sin(y * Mth.DEG_TO_RAD)));
x - persp.getLean() * Mth.sin((persp.getYaw() - y) * Mth.DEG_TO_RAD),
persp.getLean() * Mth.cos((persp.getYaw() - y) * Mth.DEG_TO_RAD));
} else setRotation(y, x);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public class PlayerRendererMixin {
return ctp$lean;
}

public float ctp$getYaw() {
return ctp$yaw;
}

@Inject(
method = "setupRotations(Lnet/minecraft/client/player/AbstractClientPlayer;Lcom/mojang/blaze3d/vertex/PoseStack;FFF)V",
at = @At(
Expand Down

0 comments on commit 4e0d971

Please sign in to comment.