From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sun, 20 Jun 2021 00:08:13 -0700 Subject: [PATCH] Do not allow ticket level changes when updating chunk ticking state This WILL cause state corruption if it happens. So, don't allow it. diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java index b6445778a023531774784f1a6e569849dda4c8ce..c70e1018c5e5b65911ee430be123e38f03666df2 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -418,7 +418,13 @@ public class ChunkHolder { CompletableFuture completablefuture1 = new CompletableFuture(); completablefuture1.thenRunAsync(() -> { + // Paper start - do not allow ticket level changes + boolean unloadingBefore = this.chunkMap.unloadingPlayerChunk; + this.chunkMap.unloadingPlayerChunk = true; + try { + // Paper end - do not allow ticket level changes playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state); + } finally { this.chunkMap.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes }, executor); this.pendingFullStateConfirmation = completablefuture1; completablefuture.thenAccept((either) -> { @@ -435,7 +441,12 @@ public class ChunkHolder { private void demoteFullChunk(ChunkMap playerchunkmap, ChunkHolder.FullChunkStatus playerchunk_state) { this.pendingFullStateConfirmation.cancel(false); + // Paper start - do not allow ticket level changes + boolean unloadingBefore = this.chunkMap.unloadingPlayerChunk; + this.chunkMap.unloadingPlayerChunk = true; + try { // Paper end - do not allow ticket level changes playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state); + } finally { this.chunkMap.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes } protected long updateCount; // Paper - correctly handle recursion