From e3e1191ac939dcdfb5e778cc916103a1a440363e Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 19 Sep 2020 13:19:34 -0400 Subject: [PATCH] Preserve initial velocity of spawned entities - Fixes #4292 --- ...ortation-and-cancel-velocity-if-tele.patch | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Spigot-Server-Patches/0575-Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch b/Spigot-Server-Patches/0575-Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch index 9eeec3ced6..6972de3236 100644 --- a/Spigot-Server-Patches/0575-Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch +++ b/Spigot-Server-Patches/0575-Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch @@ -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;