mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-02 17:01:38 +01:00
75 lines
3.1 KiB
Diff
75 lines
3.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MWHunter <s0521458@student.rockvalleycollege.edu>
|
|
Date: Wed, 24 Aug 2022 09:54:11 -0400
|
|
Subject: [PATCH] Stop large look changes from crashing the server
|
|
|
|
Co-authored-by: Jaren Knodel <Jaren@Knodel.com>
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index 98dac3d0288902265beb07ff17c5ae1bebeb2cfc..c9b072a6324e5facdb85db1caaa7e763191f7104 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -3028,37 +3028,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 b226800c15f5adbc40c89b36536db23f08e2857d..893975e8587b9036f622e2088c302e33004496d2 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
|
@@ -246,13 +246,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);
|
|
}
|