From 3aedf474ba87543ad1b2e40b8d1f488ecc4fd08b Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 4 Jun 2018 19:27:57 +0200 Subject: [PATCH] Better barrel roles! This should be less likely to break on diagonals. --- .../render/player/RenderPonyPlayer.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index 9db9c1f1..50d38729 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -50,14 +50,17 @@ public class RenderPonyPlayer extends RenderPonyBase { GlStateManager.rotate(ponyModel.motionPitch, 1, 0, 0); double horMotion = Math.sqrt(motionX * motionX + motionZ * motionZ); + if (horMotion > 0) { - yaw = (player.cameraYaw - player.rotationYaw) % 360; + + yaw = player.cameraYaw - player.rotationYawHead; + double roll = (Math.toDegrees(Math.atan2(motionX, motionZ)) - yaw) % 360; - if (roll > 180) { - roll -= 360; - } - roll = MathHelper.clamp(roll, -44, 44) * horMotion * 2; + if (roll < -180) roll += 360; + + roll *= horMotion * 2; + roll = MathHelper.clamp(roll, -54, 54); GlStateManager.rotate((float)roll, 0, 0, 1); }