diff --git a/patches/api/Async-Chunks-API.patch b/patches/api/Async-Chunks-API.patch index 61f2443870..2dbf439b93 100644 --- a/patches/api/Async-Chunks-API.patch +++ b/patches/api/Async-Chunks-API.patch @@ -498,25 +498,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param loc Location to teleport to + * @return A future that will be completed with the result of the teleport + */ -+ @NotNull -+ public default java.util.concurrent.CompletableFuture teleportAsync(@NotNull Location loc) { -+ return teleportAsync(loc, TeleportCause.PLUGIN); ++ default java.util.concurrent.@NotNull CompletableFuture teleportAsync(final @NotNull Location loc) { ++ return this.teleportAsync(loc, TeleportCause.PLUGIN); + } ++ + /** + * Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready. + * @param loc Location to teleport to + * @param cause Reason for teleport + * @return A future that will be completed with the result of the teleport + */ -+ @NotNull -+ public default java.util.concurrent.CompletableFuture teleportAsync(@NotNull Location loc, @NotNull TeleportCause cause) { -+ java.util.concurrent.CompletableFuture future = new java.util.concurrent.CompletableFuture<>(); -+ loc.getWorld().getChunkAtAsyncUrgently(loc).thenAccept((chunk) -> future.complete(teleport(loc, cause))).exceptionally(ex -> { -+ future.completeExceptionally(ex); -+ return null; -+ }); -+ return future; ++ default java.util.concurrent.@NotNull CompletableFuture teleportAsync(final @NotNull Location loc, final @NotNull TeleportCause cause) { ++ final class Holder { ++ static final io.papermc.paper.entity.TeleportFlag[] EMPTY_FLAGS = new io.papermc.paper.entity.TeleportFlag[0]; ++ } ++ return this.teleportAsync(loc, cause, Holder.EMPTY_FLAGS); + } ++ ++ /** ++ * Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready. ++ * @param loc Location to teleport to ++ * @param cause Reason for teleport ++ * @param teleportFlags Flags to be used in this teleportation ++ * @return A future that will be completed with the result of the teleport ++ */ ++ java.util.concurrent.@NotNull CompletableFuture teleportAsync(@NotNull Location loc, @NotNull TeleportCause cause, @NotNull io.papermc.paper.entity.TeleportFlag @NotNull... teleportFlags); + // Paper end + /** diff --git a/patches/server/Add-Entity-Body-Yaw-API.patch b/patches/server/Add-Entity-Body-Yaw-API.patch index 370910ce84..1adeed55ec 100644 --- a/patches/server/Add-Entity-Body-Yaw-API.patch +++ b/patches/server/Add-Entity-Body-Yaw-API.patch @@ -9,10 +9,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - public boolean isInPowderedSnow() { - return getHandle().isInPowderSnow || getHandle().wasInPowderSnow; // depending on the location in the entity "tick" either could be needed. } -+ + // Paper end - entity powdered snow API + ++ // Paper start - entity body yaw API + @Override + public double getX() { + return this.entity.getX(); @@ -37,9 +37,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public float getYaw() { + return this.entity.getBukkitYaw(); + } - // Paper end - ++ // Paper end - entity body yaw API ++ // Paper start - missing entity api + @Override + public boolean isInvisible() { // Paper - moved up from LivingEntity diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/patches/server/Add-Raw-Byte-Entity-Serialization.patch b/patches/server/Add-Raw-Byte-Entity-Serialization.patch index 96d670b2bc..25c9ea2b61 100644 --- a/patches/server/Add-Raw-Byte-Entity-Serialization.patch +++ b/patches/server/Add-Raw-Byte-Entity-Serialization.patch @@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - } - return set; } -+ + // Paper end - tracked players API + ++ // Paper start - raw entity serialization API + @Override + public boolean spawnAt(Location location, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + Preconditions.checkNotNull(location, "location cannot be null"); @@ -44,9 +44,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.entity.setRot(location.getYaw(), location.getPitch()); + return !this.entity.valid && this.entity.level().addFreshEntity(this.entity, reason); + } - // Paper end - ++ // Paper end - raw entity serialization API ++ // Paper start - missing entity api + @Override + public boolean isInvisible() { // Paper - moved up from LivingEntity diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java diff --git a/patches/server/Add-entity-liquid-API.patch b/patches/server/Add-entity-liquid-API.patch index 5eec1a6fa7..a886ec2019 100644 --- a/patches/server/Add-entity-liquid-API.patch +++ b/patches/server/Add-entity-liquid-API.patch @@ -12,10 +12,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getEntitySpawnReason() { return getHandle().spawnReason; } + // Paper end - entity spawn reason API + ++ // Paper start - entity liquid API + @Override + public boolean isUnderWater() { + return getHandle().isUnderWater(); @@ -50,5 +51,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean isInLava() { + return getHandle().isInLava(); + } - // Paper end ++ // Paper end - entity liquid API } diff --git a/patches/server/Entity-Origin-API.patch b/patches/server/Entity-Origin-API.patch index 79d7b505e5..2e1f5b6ad0 100644 --- a/patches/server/Entity-Origin-API.patch +++ b/patches/server/Entity-Origin-API.patch @@ -98,10 +98,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - - return ret; + return this.spigot; } + // Spigot end + ++ // Paper start - entity origin API + @Override + public Location getOrigin() { + Vector originVector = this.getHandle().getOriginVector(); @@ -116,5 +117,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + //noinspection ConstantConditions + return originVector.toLocation(world); + } - // Paper end ++ // Paper end - entity origin API } diff --git a/patches/server/Entity-fromMobSpawner.patch b/patches/server/Entity-fromMobSpawner.patch index fe2ec9b8fa..ae6e01661e 100644 --- a/patches/server/Entity-fromMobSpawner.patch +++ b/patches/server/Entity-fromMobSpawner.patch @@ -53,13 +53,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - //noinspection ConstantConditions return originVector.toLocation(world); } + // Paper end - entity origin API + ++ // Paper start - Entity#fromMobSpawner + @Override + public boolean fromMobSpawner() { -+ return getHandle().spawnedViaMobSpawner; ++ return this.getHandle().spawnedViaMobSpawner; + } - // Paper end ++ // Paper end - Entity#fromMobSpawner } diff --git a/patches/server/Entity-getEntitySpawnReason.patch b/patches/server/Entity-getEntitySpawnReason.patch index 6ea9bc5b1a..9446dfdda2 100644 --- a/patches/server/Entity-getEntitySpawnReason.patch +++ b/patches/server/Entity-getEntitySpawnReason.patch @@ -137,13 +137,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - public boolean fromMobSpawner() { - return getHandle().spawnedViaMobSpawner; + return this.getHandle().spawnedViaMobSpawner; } + // Paper end - Entity#fromMobSpawner + ++ // Paper start - entity spawn reason API + @Override + public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getEntitySpawnReason() { + return getHandle().spawnReason; + } - // Paper end ++ // Paper end - entity spawn reason API } diff --git a/patches/server/Entity-isTicking.patch b/patches/server/Entity-isTicking.patch index 631998949f..6cd64384d4 100644 --- a/patches/server/Entity-isTicking.patch +++ b/patches/server/Entity-isTicking.patch @@ -23,13 +23,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - public boolean isInLava() { return getHandle().isInLava(); } + // Paper end - entity liquid API + ++ // Paper start - isTicking API + @Override + public boolean isTicking() { + return getHandle().isTicking(); + } - // Paper end ++ // Paper end - isTicking API } diff --git a/patches/server/Entity-powdered-snow-API.patch b/patches/server/Entity-powdered-snow-API.patch index a1426ef7f5..7482de7258 100644 --- a/patches/server/Entity-powdered-snow-API.patch +++ b/patches/server/Entity-powdered-snow-API.patch @@ -11,17 +11,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - this.entity.setRot(location.getYaw(), location.getPitch()); - return !this.entity.valid && this.entity.level().addFreshEntity(this.entity, reason); } -+ + // Paper end - raw entity serialization API + ++ // Paper start - entity powdered snow API + @Override + public boolean isInPowderedSnow() { + return getHandle().isInPowderSnow || getHandle().wasInPowderSnow; // depending on the location in the entity "tick" either could be needed. + } - // Paper end - ++ // Paper end - entity powdered snow API ++ // Paper start - missing entity api + @Override + public boolean isInvisible() { // Paper - moved up from LivingEntity diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java diff --git a/patches/server/Expose-Tracked-Players.patch b/patches/server/Expose-Tracked-Players.patch index 951defaccf..d0b7c5a510 100644 --- a/patches/server/Expose-Tracked-Players.patch +++ b/patches/server/Expose-Tracked-Players.patch @@ -9,10 +9,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - public boolean isTicking() { return getHandle().isTicking(); } + // Paper end - isTicking API + ++ // Paper start - tracked players API + @Override + public Set getTrackedPlayers() { + if (this.entity.tracker == null) { @@ -25,5 +26,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + return set; + } - // Paper end ++ // Paper end - tracked players API } diff --git a/patches/server/MC-Utils.patch b/patches/server/MC-Utils.patch index 64a7a55535..59b880dddf 100644 --- a/patches/server/MC-Utils.patch +++ b/patches/server/MC-Utils.patch @@ -7850,48 +7850,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setSendViewDistance(final int viewDistance) { + throw new UnsupportedOperationException("Not implemented yet"); + } -+ // Paper end - } -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - return this.spigot; - } - // Spigot end -+ -+ // Paper start -+ @Override -+ public java.util.concurrent.CompletableFuture teleportAsync(Location location, TeleportCause cause) { -+ 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 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) ? 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 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/patches/server/Missing-Entity-API.patch b/patches/server/Missing-Entity-API.patch index 41b9983b39..f13e15397c 100644 --- a/patches/server/Missing-Entity-API.patch +++ b/patches/server/Missing-Entity-API.patch @@ -677,7 +677,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return set; } - // Paper end + // Paper end - tracked players API + + // Paper start - missing entity api + @Override diff --git a/patches/server/More-Teleport-API.patch b/patches/server/More-Teleport-API.patch index e6d734e568..c956008017 100644 --- a/patches/server/More-Teleport-API.patch +++ b/patches/server/More-Teleport-API.patch @@ -71,6 +71,46 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Let the server handle cross world teleports if (location.getWorld() != null && !location.getWorld().equals(this.getWorld())) { +@@ -0,0 +0,0 @@ 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 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 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java