Make CB Entity async teleport dismount entities being teleported

This preserves behavior with the older API that did
dismount the entity before teleporting

Fixes https://github.com/PaperMC/Folia/issues/36
This commit is contained in:
Spottedleaf 2023-04-08 16:56:30 -07:00
parent b1c668f2b9
commit 4431a66c12
2 changed files with 6 additions and 3 deletions

View File

@ -24385,7 +24385,7 @@ index cd4ad8261e56365850068db1d83d6a8454026737..78f7e72f2912dae503c2dab7d1992b65
List<String> offers = waitable.get();
if (offers == null) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 57a0dbb23a32123d30c3b3572f4d129be9d97847..b7b00aeadea76531d495e0478e09d3496677268c 100644
index 57a0dbb23a32123d30c3b3572f4d129be9d97847..2284570959dbaf9941e85caf723f06a032705e7e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -203,6 +203,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@ -24426,7 +24426,7 @@ index 57a0dbb23a32123d30c3b3572f4d129be9d97847..b7b00aeadea76531d495e0478e09d349
if (entityTracker == null) {
return;
@@ -1308,30 +1323,43 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1308,30 +1323,46 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
Preconditions.checkArgument(location != null, "location");
location.checkFinite();
Location locationClone = location.clone(); // clone so we don't need to worry about mutations after this call.
@ -24451,6 +24451,9 @@ index 57a0dbb23a32123d30c3b3572f4d129be9d97847..b7b00aeadea76531d495e0478e09d349
- net.minecraft.server.MinecraftServer.LOGGER.error("Failed to teleport entity " + CraftEntity.this, throwable);
- ret.completeExceptionally(throwable);
+ java.util.function.Consumer<Entity> run = (Entity nmsEntity) -> {
+ // preserve behavior with old API: dismount the entity so it can teleport
+ nmsEntity.unRide();
+
+ boolean success = nmsEntity.teleportAsync(
+ ((CraftWorld)locationClone.getWorld()).getHandle(),
+ new net.minecraft.world.phys.Vec3(locationClone.getX(), locationClone.getY(), locationClone.getZ()),

View File

@ -932,7 +932,7 @@ index 75c7645fb5732c43d1da15181cf5c7ee4c3ecd6c..6d3325436a77153438bc40aa86819562
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index b7b00aeadea76531d495e0478e09d3496677268c..ee646f97cd208120bb886db402b3dc37da0a70d5 100644
index 2284570959dbaf9941e85caf723f06a032705e7e..beccbc2dd18174ca2586b9b67f1e2f1f26840901 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -827,7 +827,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {