aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0764-More-Teleport-API.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0764-More-Teleport-API.patch')
-rw-r--r--patches/server/0764-More-Teleport-API.patch42
1 files changed, 41 insertions, 1 deletions
diff --git a/patches/server/0764-More-Teleport-API.patch b/patches/server/0764-More-Teleport-API.patch
index c593fa72c5..763d23ba14 100644
--- a/patches/server/0764-More-Teleport-API.patch
+++ b/patches/server/0764-More-Teleport-API.patch
@@ -29,7 +29,7 @@ index 5775d071f714e7b9d959bfa94510b865f489e68e..27eb4bc4d1276ea36b97d0faeed2acee
d0 = to.getX();
d1 = to.getY();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
-index 88e05b8ec5f442b3ad14e3b39a06beeca5c169ae..70c1b20c2b25fbe53255f1753d86570c975767ab 100644
+index 46bc34741394740de46546bd4ce7db35c757316c..79e58d7a72a599cd84d479be62f72c523e37dd07 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -219,15 +219,36 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -71,6 +71,46 @@ index 88e05b8ec5f442b3ad14e3b39a06beeca5c169ae..70c1b20c2b25fbe53255f1753d86570c
// Let the server handle cross world teleports
if (location.getWorld() != null && !location.getWorld().equals(this.getWorld())) {
+@@ -948,6 +969,39 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
+ return CraftEntity.perm;
+ }
+
++ // Paper start - more teleport API / async chunk API
++ @Override
++ public java.util.concurrent.CompletableFuture<Boolean> teleportAsync(final Location location, final TeleportCause cause, final io.papermc.paper.entity.TeleportFlag... teleportFlags) {
++ Preconditions.checkArgument(location != null, "location");
++ location.checkFinite();
++ Location locationClone = location.clone(); // clone so we don't need to worry about mutations after this call.
++
++ net.minecraft.server.level.ServerLevel world = ((CraftWorld)locationClone.getWorld()).getHandle();
++ java.util.concurrent.CompletableFuture<Boolean> ret = new java.util.concurrent.CompletableFuture<>();
++
++ world.loadChunksForMoveAsync(getHandle().getBoundingBoxAt(locationClone.getX(), locationClone.getY(), locationClone.getZ()),
++ this instanceof CraftPlayer ? ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGHER : ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, (list) -> {
++ net.minecraft.server.level.ServerChunkCache chunkProviderServer = world.getChunkSource();
++ for (net.minecraft.world.level.chunk.ChunkAccess chunk : list) {
++ chunkProviderServer.addTicketAtLevel(net.minecraft.server.level.TicketType.POST_TELEPORT, chunk.getPos(), 33, CraftEntity.this.getEntityId());
++ }
++ net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> {
++ try {
++ ret.complete(CraftEntity.this.teleport(locationClone, cause, teleportFlags) ? Boolean.TRUE : Boolean.FALSE);
++ } catch (Throwable throwable) {
++ if (throwable instanceof ThreadDeath) {
++ throw (ThreadDeath)throwable;
++ }
++ net.minecraft.server.MinecraftServer.LOGGER.error("Failed to teleport entity " + CraftEntity.this, throwable);
++ ret.completeExceptionally(throwable);
++ }
++ });
++ });
++
++ return ret;
++ }
++ // Paper end - more teleport API / async chunk API
++
+ // Spigot start
+ private final org.bukkit.entity.Entity.Spigot spigot = new org.bukkit.entity.Entity.Spigot()
+ {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 11e144bf561cc3c4dc1d8b712f915cc167f4d4ed..f606250106f1bcf5870dff1167f2902f85f7784a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java