Fix camera looking straight down on 1.21.2+

This commit is contained in:
Jonas Herzig
2024-12-07 14:22:51 +01:00
parent 50cfcbabfb
commit 7f7b4e1891

View File

@@ -42,6 +42,7 @@ import net.minecraft.util.math.Box;
//#if MC>=12002 //#if MC>=12002
//$$ import net.minecraft.client.util.SkinTextures; //$$ import net.minecraft.client.util.SkinTextures;
//$$ import net.minecraft.util.math.MathHelper;
//#endif //#endif
//#if MC>=11400 //#if MC>=11400
@@ -219,6 +220,11 @@ public class CameraEntity
* @param roll Roll in degrees * @param roll Roll in degrees
*/ */
public void setCameraRotation(float yaw, float pitch, float roll) { 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.prevYaw = yaw;
this.prevPitch = pitch; this.prevPitch = pitch;
this.yaw = yaw; this.yaw = yaw;