mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 13:07:06 +01:00
62 lines
4.4 KiB
Diff
62 lines
4.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
|
Date: Sat, 19 Sep 2020 15:29:16 -0700
|
|
Subject: [PATCH] Do not allow ticket level changes while unloading
|
|
playerchunks
|
|
|
|
Sync loading the chunk at this stage would cause it to load
|
|
older data, as well as screwing our region state.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
index d11c70dc9f65171827190028ebcc4db7331fff20..62d5bfe5912e13bfef4f8e65c9a030e08b2cc4aa 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
@@ -336,6 +336,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
}
|
|
// Paper end
|
|
|
|
+ boolean unloadingPlayerChunk = false; // Paper - do not allow ticket level changes while unloading chunks
|
|
private final java.util.concurrent.ExecutorService lightThread; // Paper
|
|
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureManager structureManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
|
|
super(new File(session.getDimensionPath(world.dimension()), "region"), dataFixer, dsync);
|
|
@@ -853,6 +854,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
|
|
@Nullable
|
|
ChunkHolder updateChunkScheduling(long pos, int level, @Nullable ChunkHolder holder, int k) {
|
|
+ if (this.unloadingPlayerChunk) { net.minecraft.server.MinecraftServer.LOGGER.fatal("Cannot tick distance manager while unloading playerchunks", new Throwable()); throw new IllegalStateException("Cannot tick distance manager while unloading playerchunks"); } // Paper
|
|
if (k > ChunkMap.MAX_CHUNK_DISTANCE && level > ChunkMap.MAX_CHUNK_DISTANCE) {
|
|
return holder;
|
|
} else {
|
|
@@ -1106,6 +1108,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
if (completablefuture1 != completablefuture) {
|
|
this.scheduleUnload(pos, holder);
|
|
} else {
|
|
+ // Paper start - do not allow ticket level changes while unloading chunks
|
|
+ org.spigotmc.AsyncCatcher.catchOp("playerchunk unload");
|
|
+ boolean unloadingBefore = this.unloadingPlayerChunk;
|
|
+ this.unloadingPlayerChunk = true;
|
|
+ try {
|
|
+ // Paper end - do not allow ticket level changes while unloading chunks
|
|
if (this.pendingUnloads.remove(pos, holder) && ichunkaccess != null) {
|
|
if (ichunkaccess instanceof LevelChunk) {
|
|
((LevelChunk) ichunkaccess).setLoaded(false);
|
|
@@ -1132,6 +1140,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
this.lightEngine.tryScheduleUpdate();
|
|
this.progressListener.onStatusChange(ichunkaccess.getPos(), (ChunkStatus) null);
|
|
}
|
|
+ } finally { this.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes while unloading chunks
|
|
|
|
}
|
|
};
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
|
index 6b95085a5c8c7b91a326f205e56a978deacbbebd..552d3c27abd582fcd09c8494dc0b796c4fc0291d 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -680,6 +680,7 @@ public class ServerChunkCache extends ChunkSource {
|
|
|
|
public boolean runDistanceManagerUpdates() {
|
|
if (distanceManager.delayDistanceManagerTick) return false; // Paper - Chunk priority
|
|
+ if (this.chunkMap.unloadingPlayerChunk) { net.minecraft.server.MinecraftServer.LOGGER.fatal("Cannot tick distance manager while unloading playerchunks", new Throwable()); throw new IllegalStateException("Cannot tick distance manager while unloading playerchunks"); } // Paper
|
|
boolean flag = this.distanceManager.runAllUpdates(this.chunkMap);
|
|
boolean flag1 = this.chunkMap.promoteChunkMap();
|
|
|