diff --git a/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch b/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch index 95800dbb33..5e1792e7f6 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch @@ -10,7 +10,7 @@ + if (chunk == null) { + return false; + } -+ return chunk.getFullChunk() != null; ++ return chunk.getFullChunkNow() != null; + } + + public Chunk getChunkUnchecked(int chunkX, int chunkZ) { @@ -18,7 +18,7 @@ + if (chunk == null) { + return null; + } -+ return chunk.getFullChunk(); ++ return chunk.getFullChunkNowUnchecked(); + } + // CraftBukkit end + diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch index 096d1de42c..aef789f31d 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch @@ -25,7 +25,28 @@ this.pos = chunkcoordintpair; this.levelHeightAccessor = levelheightaccessor; this.lightEngine = lightengine; -@@ -117,17 +121,17 @@ +@@ -92,6 +96,20 @@ + this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()]; + } + ++ // CraftBukkit start ++ public Chunk getFullChunkNow() { ++ // Note: We use the oldTicketLevel for isLoaded checks. ++ if (!getFullChunkStatus(this.oldTicketLevel).isOrAfter(PlayerChunk.State.BORDER)) return null; ++ return this.getFullChunkNowUnchecked(); ++ } ++ ++ public Chunk getFullChunkNowUnchecked() { ++ CompletableFuture> statusFuture = this.getFutureIfPresentUnchecked(ChunkStatus.FULL); ++ Either either = (Either) statusFuture.getNow(null); ++ return (either == null) ? null : (Chunk) either.left().orElse(null); ++ } ++ // CraftBukkit end ++ + public CompletableFuture> getFutureIfPresentUnchecked(ChunkStatus chunkstatus) { + CompletableFuture> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.getIndex()); + +@@ -117,17 +135,17 @@ @Nullable public Chunk getTickingChunk() { CompletableFuture> completablefuture = this.getTickingChunkFuture(); @@ -47,7 +68,7 @@ } @Nullable -@@ -172,6 +176,7 @@ +@@ -172,6 +190,7 @@ if (chunk != null) { int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY()); @@ -55,7 +76,7 @@ if (this.changedBlocksPerSection[i] == null) { this.hasChangedSections = true; this.changedBlocksPerSection[i] = new ShortOpenHashSet(); -@@ -368,7 +373,7 @@ +@@ -368,7 +387,7 @@ this.pendingFullStateConfirmation = completablefuture1; completablefuture.thenAccept((either) -> { either.ifLeft((chunk) -> { @@ -64,7 +85,7 @@ }); }); } -@@ -385,6 +390,30 @@ +@@ -385,6 +404,30 @@ boolean flag1 = this.ticketLevel <= PlayerChunkMap.MAX_CHUNK_DISTANCE; PlayerChunk.State playerchunk_state = getFullChunkStatus(this.oldTicketLevel); PlayerChunk.State playerchunk_state1 = getFullChunkStatus(this.ticketLevel); @@ -95,7 +116,7 @@ if (flag) { Either either = Either.right(new PlayerChunk.Failure() { -@@ -455,6 +484,26 @@ +@@ -455,6 +498,26 @@ this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel); this.oldTicketLevel = this.ticketLevel; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 578072f980..c9c3d798dc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -231,7 +231,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Chunk[] getLoadedChunks() { Long2ObjectLinkedOpenHashMap chunks = world.getChunkSource().chunkMap.visibleChunkMap; - return chunks.values().stream().map(PlayerChunk::getFullChunk).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.Chunk::getBukkitChunk).toArray(Chunk[]::new); + return chunks.values().stream().map(PlayerChunk::getFullChunkNow).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.Chunk::getBukkitChunk).toArray(Chunk[]::new); } @Override