Paper/Spigot-Server-Patches/0405-Use-ChunkStatus-cache-when-saving-protochunks.patch
Spottedleaf 36c4831619 Fix loadChunk(x, z, false)
I was not correctly checking if the status was even cached.

Actually fix it this time

Do not forget about the async chunk placeholder

Actually fix it this time I hope

No plugin tickets for getChunkAtGen(x, z, boolean)

Change ChunkStatus ABI

This is required for asynchronous IO. async io will require
calls to getChunkStatusIfCached to return the chunk status for a
chunk currently queued to save - this cannot be reasonably done
with current ABI
2019-07-13 13:18:54 -07:00

29 lines
1.4 KiB
Diff

From ba7006117301143d6877b70bfd4f0043feb4fa5d Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 22 Jun 2019 04:20:47 -0700
Subject: [PATCH] Use ChunkStatus cache when saving protochunks
The cache should contain the chunk status when saving. If not it
will load it.
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index e2f8b18d9..7cb5438e4 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -723,8 +723,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
NBTTagCompound nbttagcompound;
if (chunkstatus.getType() != ChunkStatus.Type.LEVELCHUNK) {
- nbttagcompound = this.readChunkData(chunkcoordintpair);
- if (nbttagcompound != null && ChunkRegionLoader.a(nbttagcompound) == ChunkStatus.Type.LEVELCHUNK) {
+ // Paper start - Optimize save by using status cache
+ ChunkStatus statusOnDisk = this.getChunkStatusOnDisk(chunkcoordintpair);
+ if (statusOnDisk != null && statusOnDisk.getType() == ChunkStatus.Type.LEVELCHUNK) {
+ // Paper end
return false;
}
--
2.22.0