diff --git a/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/PlayerPerspectiveBehavior.java b/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/PlayerPerspectiveBehavior.java index 1b39cfc..c20ce51 100644 --- a/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/PlayerPerspectiveBehavior.java +++ b/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/PlayerPerspectiveBehavior.java @@ -6,4 +6,5 @@ public interface PlayerPerspectiveBehavior { void setLean(float lean); void setYaw(float yaw); float getLean(); + float getYaw(); } diff --git a/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/mixin/CameraMixin.java b/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/mixin/CameraMixin.java index eac46d6..60fdd59 100644 --- a/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/mixin/CameraMixin.java +++ b/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/mixin/CameraMixin.java @@ -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); } } diff --git a/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/mixin/PlayerRendererMixin.java b/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/mixin/PlayerRendererMixin.java index e35508f..f9c0dd9 100644 --- a/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/mixin/PlayerRendererMixin.java +++ b/common/src/main/java/net/derfruhling/minecraft/create/trainperspective/mixin/PlayerRendererMixin.java @@ -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(