From 267dd180b6252922bd4007a0ced59e88e7ac49ac Mon Sep 17 00:00:00 2001 From: Jaren Date: Fri, 16 Sep 2022 23:30:00 -0400 Subject: [PATCH] Stop large look changes from crashing the server (#8326) --- ...ook-changes-from-crashing-the-server.patch | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 patches/server/0936-Stop-large-look-changes-from-crashing-the-server.patch diff --git a/patches/server/0936-Stop-large-look-changes-from-crashing-the-server.patch b/patches/server/0936-Stop-large-look-changes-from-crashing-the-server.patch new file mode 100644 index 000000000..982641cfd --- /dev/null +++ b/patches/server/0936-Stop-large-look-changes-from-crashing-the-server.patch @@ -0,0 +1,74 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MWHunter +Date: Wed, 24 Aug 2022 09:54:11 -0400 +Subject: [PATCH] Stop large look changes from crashing the server + +Co-authored-by: Jaren Knodel + +diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java +index cff7993bdafd2f69e46c9985c7601a69ae47f452..99f997e63620492de737a68904ec9e9929096bff 100644 +--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +@@ -2986,37 +2986,15 @@ public abstract class LivingEntity extends Entity { + this.level.getProfiler().pop(); + this.level.getProfiler().push("rangeChecks"); + +- while (this.getYRot() - this.yRotO < -180.0F) { +- this.yRotO -= 360.0F; +- } +- +- while (this.getYRot() - this.yRotO >= 180.0F) { +- this.yRotO += 360.0F; +- } ++ // Paper start - stop large pitch and yaw changes from crashing the server ++ this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; + +- while (this.yBodyRot - this.yBodyRotO < -180.0F) { +- this.yBodyRotO -= 360.0F; +- } ++ this.yBodyRotO += Math.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F; + +- while (this.yBodyRot - this.yBodyRotO >= 180.0F) { +- this.yBodyRotO += 360.0F; +- } +- +- while (this.getXRot() - this.xRotO < -180.0F) { +- this.xRotO -= 360.0F; +- } ++ this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F; + +- while (this.getXRot() - this.xRotO >= 180.0F) { +- this.xRotO += 360.0F; +- } +- +- while (this.yHeadRot - this.yHeadRotO < -180.0F) { +- this.yHeadRotO -= 360.0F; +- } +- +- while (this.yHeadRot - this.yHeadRotO >= 180.0F) { +- this.yHeadRotO += 360.0F; +- } ++ this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F; ++ // Paper end + + this.level.getProfiler().pop(); + this.animStep += f2; +diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +index 66c3f374a779cd3a4548393ba23e9219f1caf6d3..c61ed38d0a824fee9b45acfc862baf03c85fe54b 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +@@ -245,13 +245,7 @@ public abstract class Projectile extends Entity { + } + + protected static float lerpRotation(float prevRot, float newRot) { +- while (newRot - prevRot < -180.0F) { +- prevRot -= 360.0F; +- } +- +- while (newRot - prevRot >= 180.0F) { +- prevRot += 360.0F; +- } ++ prevRot += Math.round((newRot - prevRot) / 360.0F) * 360.0F; // Paper - stop large look changes from crashing the server + + return Mth.lerp(0.2F, prevRot, newRot); + }