From 7f7b4e1891fe3f5c00c3714765aa6050649bb9d5 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sat, 7 Dec 2024 14:22:51 +0100 Subject: [PATCH] Fix camera looking straight down on 1.21.2+ --- src/main/java/com/replaymod/replay/camera/CameraEntity.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/replaymod/replay/camera/CameraEntity.java b/src/main/java/com/replaymod/replay/camera/CameraEntity.java index 5f62d9d3..024d56a1 100644 --- a/src/main/java/com/replaymod/replay/camera/CameraEntity.java +++ b/src/main/java/com/replaymod/replay/camera/CameraEntity.java @@ -42,6 +42,7 @@ import net.minecraft.util.math.Box; //#if MC>=12002 //$$ import net.minecraft.client.util.SkinTextures; +//$$ import net.minecraft.util.math.MathHelper; //#endif //#if MC>=11400 @@ -219,6 +220,11 @@ public class CameraEntity * @param roll Roll in degrees */ public void setCameraRotation(float yaw, float pitch, float roll) { + //#if MC>=12102 + //$$ // Note: MC's `setPitch` now forces values into the [-90; 90] range, however the math it uses is incorrect, so + //$$ // we need to wrap our value into the [-180; 180] range first to get correct results. + //$$ pitch = MathHelper.wrapDegrees(pitch); + //#endif this.prevYaw = yaw; this.prevPitch = pitch; this.yaw = yaw;