mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 08:20:51 +01:00
3c0d6aaed9
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 0c7aedbc SPIGOT-7554, PR-954: Add DecoratedPotInventory CraftBukkit Changes: 53ebb05e3 SPIGOT-7554, PR-1323: Add DecoratedPotInventory 33a2d8773 Ensure that PlayerMoveEvent is always fired where applicable 7df18510f SPIGOT-7555: Don't cast ItemFlags to byte 19aec59ea Use provided case for non-existent OfflinePlayers Spigot Changes: e7ce55a3 Remove obsolete PlayerMoveEvent improvements 3e5e22c0 Remove obsolete lowercasing of non existent OfflinePlayer names
84 lines
5.0 KiB
Diff
84 lines
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Tue, 25 Aug 2020 20:45:36 -0400
|
|
Subject: [PATCH] Fix Entity Teleportation and cancel velocity if teleported
|
|
|
|
Uses correct setPositionRotation for Entity teleporting instead of setLocation
|
|
as this is how Vanilla teleports entities.
|
|
|
|
Cancel any pending motion when teleported.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 9c0cc06f4ebbfbd7959f05cae12a9f9e7e622c04..0d4e641187b305c4b56782b4c70bca39efcaa69c 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -657,7 +657,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
return;
|
|
}
|
|
|
|
- this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
|
+ this.player.moveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); // Paper - use proper moveTo for teleportation
|
|
this.lastGoodX = this.awaitingPositionFromClient.x;
|
|
this.lastGoodY = this.awaitingPositionFromClient.y;
|
|
this.lastGoodZ = this.awaitingPositionFromClient.z;
|
|
@@ -1587,7 +1587,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
// CraftBukkit end
|
|
|
|
this.awaitingTeleportTime = this.tickCount;
|
|
- this.player.absMoveTo(d0, d1, d2, f, f1);
|
|
+ this.player.moveTo(d0, d1, d2, f, f1); // Paper - use proper moveTo for teleportation
|
|
this.player.connection.send(new ClientboundPlayerPositionPacket(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport));
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 0924677535ba455a2118f7022bdd361c609022d4..452789dc47393580374bf438e6229b1e6cd3832b 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -160,6 +160,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
|
|
// CraftBukkit start
|
|
private static final int CURRENT_LEVEL = 2;
|
|
+ public boolean preserveMotion = true; // Paper - keep initial motion on first setPositionRotation
|
|
static boolean isLevelAtLeast(CompoundTag tag, int level) {
|
|
return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
|
}
|
|
@@ -1869,6 +1870,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
}
|
|
|
|
public void moveTo(double x, double y, double z, float yaw, float pitch) {
|
|
+ // Paper - cancel entity velocity if teleported
|
|
+ if (!preserveMotion) {
|
|
+ this.deltaMovement = Vec3.ZERO;
|
|
+ } else {
|
|
+ this.preserveMotion = false;
|
|
+ }
|
|
+ // Paper end
|
|
this.setPosRaw(x, y, z);
|
|
this.setYRot(yaw);
|
|
this.setXRot(pitch);
|
|
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
|
index 41f549f16f69f9bc50a004096e6c3c0f6e4d4eaf..9ec83d6eeff22c2ce25374a83f581a675d4fd067 100644
|
|
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
|
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
|
@@ -169,6 +169,7 @@ public abstract class BaseSpawner {
|
|
return;
|
|
}
|
|
|
|
+ entity.preserveMotion = true; // Paper - preserve entity motion from tag
|
|
entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F);
|
|
if (entity instanceof Mob) {
|
|
Mob entityinsentient = (Mob) entity;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index c17bb16567ad2354dc80e710469730b1dbc55b08..d5e8c8ed7528cdac203a7594ccf9576db0e5f019 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -237,7 +237,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
}
|
|
|
|
// entity.setLocation() throws no event, and so cannot be cancelled
|
|
- this.entity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
|
+ entity.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); // Paper - use proper moveTo, as per vanilla teleporting
|
|
// SPIGOT-619: Force sync head rotation also
|
|
this.entity.setYHeadRot(location.getYaw());
|
|
|