From 682bb3f9c02f7fee379f4c6f7e9aaa79f0112c02 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 23 Nov 2021 21:07:19 +0100 Subject: [PATCH] Fix mappingregistry, readd an async chunk hunk --- .../api/Inventory-removeItemAnySlot.patch | 0 .../Asynchronous-chunk-IO-and-loading.patch | 30 +++++++++---------- patches/server/Optimize-MappedRegistry.patch | 3 +- 3 files changed, 15 insertions(+), 18 deletions(-) rename patches/{unapplied => }/api/Inventory-removeItemAnySlot.patch (100%) rename patches/{unapplied => }/server/Asynchronous-chunk-IO-and-loading.patch (99%) diff --git a/patches/unapplied/api/Inventory-removeItemAnySlot.patch b/patches/api/Inventory-removeItemAnySlot.patch similarity index 100% rename from patches/unapplied/api/Inventory-removeItemAnySlot.patch rename to patches/api/Inventory-removeItemAnySlot.patch diff --git a/patches/unapplied/server/Asynchronous-chunk-IO-and-loading.patch b/patches/server/Asynchronous-chunk-IO-and-loading.patch similarity index 99% rename from patches/unapplied/server/Asynchronous-chunk-IO-and-loading.patch rename to patches/server/Asynchronous-chunk-IO-and-loading.patch index 53fd0a6de3..f2e23de52b 100644 --- a/patches/unapplied/server/Asynchronous-chunk-IO-and-loading.patch +++ b/patches/server/Asynchronous-chunk-IO-and-loading.patch @@ -2563,13 +2563,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.level.getProfiler().incrementCounter("chunkSave"); - CompoundTag nbttagcompound = ChunkSerializer.write(this.level, chunk); -- -- this.write(chunkcoordintpair, nbttagcompound); + CompoundTag nbttagcompound; + try (co.aikar.timings.Timing ignored1 = this.level.timings.chunkSaveDataSerialization.startTiming()) { // Paper + nbttagcompound = ChunkSerializer.write(this.level, chunk); -+ } // Paper; -+ ++ } // Paper + +- this.write(chunkcoordintpair, nbttagcompound); + // Paper start - async chunk io + com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE.scheduleSave(this.level, chunkcoordintpair.x, chunkcoordintpair.z, + null, nbttagcompound, com.destroystokyo.paper.io.PrioritizedTaskQueue.NORMAL_PRIORITY); @@ -2998,14 +2997,6 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -@@ -0,0 +0,0 @@ import net.minecraft.world.level.lighting.LevelLightEngine; - import net.minecraft.world.level.material.Fluid; - import net.minecraft.world.ticks.LevelChunkTicks; - import net.minecraft.world.ticks.ProtoChunkTicks; -+import net.minecraft.world.ticks.TickContainerAccess; - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - @@ -0,0 +0,0 @@ public class ChunkSerializer { public ChunkSerializer() {} @@ -3049,6 +3040,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Registry iregistry = world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); @@ -0,0 +0,0 @@ public class ChunkSerializer { + LevelChunkSection chunksection = new LevelChunkSection(b0, datapaletteblock, datapaletteblock1); + + achunksection[k] = chunksection; ++ tasksToExecuteOnMain.add(() -> { // Paper - delay this task since we're executing off-main + poiStorage.checkConsistencyWithBlocks(chunkPos, chunksection); ++ }); // Paper - delay this task since we're executing off-main + } if (flag) { if (nbttagcompound1.contains("BlockLight", 7)) { @@ -3138,7 +3136,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + skyLight[i - lightenginethreaded.getMinLightSection()] = skyArray; + } + -+ TickContainerAccess blockTickList = chunk.getBlockTicks(); ++ net.minecraft.world.ticks.TickContainerAccess blockTickList = chunk.getBlockTicks(); + + //TODO check ChunkSerializer "block_ticks" + ListTag blockTickListSerialized; @@ -3148,7 +3146,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + blockTickListSerialized = world.getBlockTicks().save(chunkPos); + } + -+ TickContainerAccess fluidTickList = chunk.getFluidTicks(); ++ net.minecraft.world.ticks.TickContainerAccess fluidTickList = chunk.getFluidTicks(); + + //TODO + ListTag fluidTickListSerialized; @@ -3378,7 +3376,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } // Paper end } - + diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -3565,7 +3563,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Map map = Maps.newHashMap(); @@ -0,0 +0,0 @@ public class SectionStorage implements AutoCloseable { - + @Override public void close() throws IOException { - this.worker.close(); diff --git a/patches/server/Optimize-MappedRegistry.patch b/patches/server/Optimize-MappedRegistry.patch index 84e67d9ba8..58e056332a 100644 --- a/patches/server/Optimize-MappedRegistry.patch +++ b/patches/server/Optimize-MappedRegistry.patch @@ -29,10 +29,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Nullable protected Object[] randomCache; @@ -0,0 +0,0 @@ public class MappedRegistry extends WritableRegistry { - public MappedRegistry(ResourceKey> key, Lifecycle lifecycle) { super(key, lifecycle); -- this.elementsLifecycle = lifecycle; + this.elementsLifecycle = lifecycle; + this.toId.defaultReturnValue(-1); // Paper }