Preserve initial velocity of spawned entities - Fixes #4292

This commit is contained in:
Aikar 2020-09-19 13:19:34 -04:00
parent bd648dfb47
commit e3e1191ac9
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
1 changed files with 17 additions and 3 deletions

View File

@ -9,14 +9,28 @@ as this is how Vanilla teleports entities.
Cancel any pending motion when teleported.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 3e6ccdd5b54dbe51d4ee9ec979cbc2d0f335be70..abdc68fce1ebb70ab6a25188ec1773ccbb8f37a6 100644
index 3e6ccdd5b54dbe51d4ee9ec979cbc2d0f335be70..5e1978d1c96dede07ead967c1e85a352348e7777 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1316,6 +1316,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@@ -54,6 +54,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
// CraftBukkit start
private static final int CURRENT_LEVEL = 2;
+ boolean preserveMotion = true; // Paper - keep initial motion on first setPositionRotation
static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
}
@@ -1316,6 +1317,13 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
public void setPositionRotation(double d0, double d1, double d2, float f, float f1) {
+ this.mot = new Vec3D(0, 0, 0); // Paper - cancel entity velocity if teleported
+ // Paper - cancel entity velocity if teleported
+ if (!preserveMotion) {
+ this.mot = Vec3D.ORIGIN;
+ } else {
+ this.preserveMotion = false;
+ }
+ // Paper end
this.g(d0, d1, d2);
this.yaw = f;
this.pitch = f1;