diff --git a/patches/server/0854-Replace-player-chunk-loader-system.patch b/patches/server/0854-Replace-player-chunk-loader-system.patch index c06805bfb..84d8c4242 100644 --- a/patches/server/0854-Replace-player-chunk-loader-system.patch +++ b/patches/server/0854-Replace-player-chunk-loader-system.patch @@ -2079,10 +2079,38 @@ index d870cefbe5b7485f423817f4f639e3e2a304640c..2292cb0e0c1a3e0ed34b941f028136bf @Nullable diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 73e7181655b78f5bff90d07edfe6c5408cc08235..1e179d8ff339c6647fed1a3d2a1c010737d37dc6 100644 +index 73e7181655b78f5bff90d07edfe6c5408cc08235..cf6fce4f3bddcbbae59fd128cf661e4506b9d2c5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -2234,43 +2234,56 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -483,10 +483,14 @@ public class CraftWorld extends CraftRegionAccessor implements World { + ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z)); + if (playerChunk == null) return false; + +- playerChunk.getTickingChunkFuture().thenAccept(either -> { +- either.left().ifPresent(chunk -> { ++ // Paper start - rewrite player chunk loader ++ net.minecraft.world.level.chunk.LevelChunk chunk = playerChunk.getSendingChunk(); ++ if (chunk == null) { ++ return false; ++ } ++ // Paper end - rewrite player chunk loader + List playersInRange = playerChunk.playerProvider.getPlayers(playerChunk.getPos(), false); +- if (playersInRange.isEmpty()) return; ++ if (playersInRange.isEmpty()) return true; // Paper - rewrite player chunk loader + + // Paper start - Anti-Xray - Bypass + Map refreshPackets = new HashMap<>(); +@@ -499,8 +503,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { + })); + // Paper end + } +- }); +- }); ++ // Paper - rewrite player chunk loader + + return true; + } +@@ -2234,43 +2237,56 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Spigot start @Override public int getViewDistance() { diff --git a/patches/server/0857-Fix-falling-block-spawn-methods.patch b/patches/server/0857-Fix-falling-block-spawn-methods.patch index f72c2de50..c8f73c8b5 100644 --- a/patches/server/0857-Fix-falling-block-spawn-methods.patch +++ b/patches/server/0857-Fix-falling-block-spawn-methods.patch @@ -21,10 +21,10 @@ index d1fca0e3227b5f37c11367548be362f5a49b6a71..5628940cd3c3566c5db2beda506d4f20 if (Snowball.class.isAssignableFrom(clazz)) { entity = new net.minecraft.world.entity.projectile.Snowball(world, x, y, z); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 1e179d8ff339c6647fed1a3d2a1c010737d37dc6..ea26283265902cf05151283c4abc7db9e30f2559 100644 +index cf6fce4f3bddcbbae59fd128cf661e4506b9d2c5..23c68b6cd26fbd05685ebcfbb5e81db4c8dedb29 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -1405,7 +1405,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1408,7 +1408,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { Validate.notNull(material, "Material cannot be null"); Validate.isTrue(material.isBlock(), "Material must be a block"); @@ -38,7 +38,7 @@ index 1e179d8ff339c6647fed1a3d2a1c010737d37dc6..ea26283265902cf05151283c4abc7db9 return (FallingBlock) entity.getBukkitEntity(); } -@@ -1414,7 +1419,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1417,7 +1422,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { Validate.notNull(location, "Location cannot be null"); Validate.notNull(data, "BlockData cannot be null"); diff --git a/patches/server/0882-Pass-ServerLevel-for-gamerule-callbacks.patch b/patches/server/0882-Pass-ServerLevel-for-gamerule-callbacks.patch index cb27fe4e4..968522daa 100644 --- a/patches/server/0882-Pass-ServerLevel-for-gamerule-callbacks.patch +++ b/patches/server/0882-Pass-ServerLevel-for-gamerule-callbacks.patch @@ -158,10 +158,10 @@ index 3c93bfeb94168f832904a8462ae23b06e81e080d..468c635d31cfa8051666bbefce8df4b4 this.onChanged(server); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index ea26283265902cf05151283c4abc7db9e30f2559..d5f2a83296ae25e41629f3ab114c067dda1c7f33 100644 +index 23c68b6cd26fbd05685ebcfbb5e81db4c8dedb29..9d27b093922f3dee9b459f8a9cdfa96f12f2e654 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -1909,7 +1909,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1912,7 +1912,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper end GameRules.Value handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule)); handle.deserialize(event.getValue()); // Paper @@ -170,7 +170,7 @@ index ea26283265902cf05151283c4abc7db9e30f2559..d5f2a83296ae25e41629f3ab114c067d return true; } -@@ -1949,7 +1949,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1952,7 +1952,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper end GameRules.Value handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule.getName())); handle.deserialize(event.getValue()); // Paper diff --git a/patches/server/0923-Warn-on-plugins-accessing-faraway-chunks.patch b/patches/server/0923-Warn-on-plugins-accessing-faraway-chunks.patch index 6b7a35a42..e66ae073c 100644 --- a/patches/server/0923-Warn-on-plugins-accessing-faraway-chunks.patch +++ b/patches/server/0923-Warn-on-plugins-accessing-faraway-chunks.patch @@ -18,7 +18,7 @@ index 9467ccaa1d73e1913495a46919aee530e749977d..5a2a1d394852d39ea576624586f7fa73 private static boolean isOutsideSpawnableHeight(int y) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index d5f2a83296ae25e41629f3ab114c067dda1c7f33..4c5145ed32a22080a88d25e2dbb7cfde2f6bbc4f 100644 +index 9d27b093922f3dee9b459f8a9cdfa96f12f2e654..1b6ae90acffa06502902e11473b65c8431616b05 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -313,9 +313,24 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -54,7 +54,7 @@ index d5f2a83296ae25e41629f3ab114c067dda1c7f33..4c5145ed32a22080a88d25e2dbb7cfde // Paper start - implement regenerateChunk method final ServerLevel serverLevel = this.world; final net.minecraft.server.level.ServerChunkCache serverChunkCache = serverLevel.getChunkSource(); -@@ -513,6 +529,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -516,6 +532,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean loadChunk(int x, int z, boolean generate) { org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot @@ -62,7 +62,7 @@ index d5f2a83296ae25e41629f3ab114c067dda1c7f33..4c5145ed32a22080a88d25e2dbb7cfde // Paper start - Optimize this method ChunkPos chunkPos = new ChunkPos(x, z); ChunkAccess immediate = world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); // Paper -@@ -577,6 +594,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -580,6 +597,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean addPluginChunkTicket(int x, int z, Plugin plugin) { @@ -70,7 +70,7 @@ index d5f2a83296ae25e41629f3ab114c067dda1c7f33..4c5145ed32a22080a88d25e2dbb7cfde Preconditions.checkArgument(plugin != null, "null plugin"); Preconditions.checkArgument(plugin.isEnabled(), "plugin is not enabled"); -@@ -658,6 +676,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -661,6 +679,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setChunkForceLoaded(int x, int z, boolean forced) { @@ -78,7 +78,7 @@ index d5f2a83296ae25e41629f3ab114c067dda1c7f33..4c5145ed32a22080a88d25e2dbb7cfde this.getHandle().setChunkForced(x, z, forced); } -@@ -969,6 +988,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -972,6 +991,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { @@ -86,7 +86,7 @@ index d5f2a83296ae25e41629f3ab114c067dda1c7f33..4c5145ed32a22080a88d25e2dbb7cfde // Transient load for this tick return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z); } -@@ -2330,6 +2350,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2333,6 +2353,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Spigot end // Paper start public java.util.concurrent.CompletableFuture getChunkAtAsync(int x, int z, boolean gen, boolean urgent) {