Paper/patches/server/0738-Do-not-allow-ticket-level-changes-when-updating-chun.patch
Spottedleaf 286bd1bfb5
1.18 misc performance dev branch (#7368)
- Port player chunk loader patch
Makes the chunk system act as it did in 1.17, no additional tickets (and thus logic) to make a chunk ticking.
Adds simulation distance API, deprecates old no-tick method.
- More collision optimisations
Ancient patch from tuinity that never could be pushed to master.
- Fix Optimise ArraySetSorted#removeIf patch
- Execute chunk tasks fairly for worlds while waiting for next tick
- Port Replace ticket level propagator
2022-02-18 09:44:46 -08:00

41 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
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 49247d12e743f987113524121e60a3e0ba4a825a..b473a0e3235405dde46d9d6cb300e88d6b1d121b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -423,7 +423,13 @@ public class ChunkHolder {
CompletableFuture<Void> 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) -> {
@@ -440,7 +446,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