diff --git a/patches/server/0018-Add-configurable-region-format-framework-linear-v2-r.patch b/patches/server/0018-Add-configurable-region-format-framework-linear-v2-r.patch index e4bab57..5e8afd7 100644 --- a/patches/server/0018-Add-configurable-region-format-framework-linear-v2-r.patch +++ b/patches/server/0018-Add-configurable-region-format-framework-linear-v2-r.patch @@ -68,10 +68,10 @@ index 0000000000000000000000000000000000000000..d92f1d549c7e01daa6b5bba7d405e462 +} diff --git a/src/main/java/abomination/LinearRegionFile.java b/src/main/java/abomination/LinearRegionFile.java new file mode 100644 -index 0000000000000000000000000000000000000000..4b4a0f9b514909debf36e0937338f27eb2f99239 +index 0000000000000000000000000000000000000000..192572f2672b9afb8c593dbf96ba95225bf985dc --- /dev/null +++ b/src/main/java/abomination/LinearRegionFile.java -@@ -0,0 +1,668 @@ +@@ -0,0 +1,666 @@ +package abomination; + +import ca.spottedleaf.concurrentutil.executor.PrioritisedExecutor; @@ -593,12 +593,10 @@ index 0000000000000000000000000000000000000000..4b4a0f9b514909debf36e0937338f27e + final PrioritisedExecutor.PrioritisedTask created = linearIOExecutor.createTask(() -> { + try { + synchronized (this) { -+ if (!this.isMarkedToSave() && !this.close) { -+ return; ++ if (!this.close) { ++ this.flush(); + } + } -+ -+ this.flush(); + } catch (IOException e) { + throw new RuntimeException(e); + } @@ -780,12 +778,24 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..c7d4d944eb198ac53a3eeae717a25c7d - public void moonrise$write(final RegionFile regionFile) throws IOException; + public void moonrise$write(final abomination.IRegionFile regionFile) throws IOException; // Luminol - Configurable region file format } +diff --git a/src/main/java/me/earthme/luminol/config/LuminolConfig.java b/src/main/java/me/earthme/luminol/config/LuminolConfig.java +index 976cc572861174787b37992388a03ab01f8703a4..fcacd381e4a5875ed0c542a9e6c1804fae823435 100644 +--- a/src/main/java/me/earthme/luminol/config/LuminolConfig.java ++++ b/src/main/java/me/earthme/luminol/config/LuminolConfig.java +@@ -77,6 +77,7 @@ public class LuminolConfig { + loadAllModules(); + }catch (Exception e){ + logger.error("Failed to load config modules!",e); ++ throw new RuntimeException(e); + } + + configFileInstance.save(); diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..d755934d41ed7cbcf26bc9f5682984a732edd18a +index 0000000000000000000000000000000000000000..60546260cd1d535cc596485de2ced48b7e045b3a --- /dev/null +++ b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java -@@ -0,0 +1,50 @@ +@@ -0,0 +1,48 @@ +package me.earthme.luminol.config.modules.misc; + +import abomination.LinearRegionFile; @@ -804,8 +814,6 @@ index 0000000000000000000000000000000000000000..d755934d41ed7cbcf26bc9f5682984a7 + public static int linearCompressionLevel = 1; + @ConfigInfo(baseName = "linear_io_thread_count") + public static int linearIoThreadCount = 6; -+ @ConfigInfo(baseName = "linear_io_signal_check_delay_ms") -+ public static int linearIoQueueSize = 100; + + @DoNotLoad + public static EnumRegionFormat regionFormat; @@ -922,6 +930,28 @@ index 8cc0c01a19fc71753d7c3ed4fa7e9992aaf93b5a..88be8a6232bc3311cc0bdb7c697f7a78 // Folia start - region threading this.stopPart2(); } +diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java +index 622d0cbe023774d92d212f242b60b96317720835..b34b2519a2abccd1d60edb7a89cb080541df18d0 100644 +--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java ++++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java +@@ -75,7 +75,7 @@ public class WorldUpgrader implements AutoCloseable { + volatile int skipped; + final Reference2FloatMap> progressMap = Reference2FloatMaps.synchronize(new Reference2FloatOpenHashMap()); + volatile Component status = Component.translatable("optimizeWorld.stage.counting"); +- static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); ++ static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\\\"+ net.minecraft.world.level.chunk.storage.RegionFileStorage.getExtensionName() +"$"); // Luminol - Configurable region file format + final DimensionDataStorage overworldDataStorage; + + public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, RegistryAccess dynamicRegistryManager, boolean eraseCache, boolean recreateRegionFiles) { +@@ -399,7 +399,7 @@ public class WorldUpgrader implements AutoCloseable { + + private static List getAllChunkPositions(RegionStorageInfo key, Path regionDirectory) { + File[] afile = regionDirectory.toFile().listFiles((file, s) -> { +- return s.endsWith(".mca"); ++ return s.endsWith(net.minecraft.world.level.chunk.storage.RegionFileStorage.getExtensionName()); // Luminol - Configurable region file format + }); + + if (afile == null) { diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java index 16f07007a0f73ec0c6f421c9b082518e87e8cc7b..fc69834e18e0860750d878e1361722fc38b513f8 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -985,7 +1015,7 @@ index 16f07007a0f73ec0c6f421c9b082518e87e8cc7b..fc69834e18e0860750d878e1361722fc } // Paper end - rewrite chunk system 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 e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a09ff02da 100644 +index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9fcf450d0c 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -23,7 +23,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @@ -997,9 +1027,12 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a private final RegionStorageInfo info; private final Path folder; private final boolean sync; -@@ -35,6 +35,26 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -33,8 +33,33 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + private static final int MAX_NON_EXISTING_CACHE = 1024 * 4; + private final it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet nonExistingRegionFiles = new it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet(); private static String getRegionFileName(final int chunkX, final int chunkZ) { - return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + ".mca"; +- return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + ".mca"; ++ return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + getExtensionName(); // Luminol - Configurable region file format } + // Luminol start - Configurable region file format + protected abomination.IRegionFile createNew(RegionStorageInfo info, Path filePath, Path folder, boolean sync) throws IOException{ @@ -1015,16 +1048,21 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a + } + + if (!regionFormat.getArgument().equalsIgnoreCase(argument)) { -+ throw new IOException("Invalid region file format: " + argument + " expected " + regionFormat.getArgument()); ++ net.minecraft.server.MinecraftServer.setFatalException(new RuntimeException("Invalid region file format: " + argument + " expected " + regionFormat.getArgument())); ++ throw new IOException("Invalid region file format: ." + argument + " expected " + regionFormat.getArgument()); + } + + return regionFormat.getCreator().create(new me.earthme.luminol.utils.RegionCreatorInfo(info, filePath, folder, sync)); + } ++ ++ public static String getExtensionName() { ++ return me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormat.getArgument(); ++ } + // Luminol end private boolean doesRegionFilePossiblyExist(final long position) { synchronized (this.nonExistingRegionFiles) { -@@ -68,15 +88,15 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -68,15 +93,15 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise } @Override @@ -1043,7 +1081,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a if (ret != null) { return ret; } -@@ -100,7 +120,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -100,7 +125,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise FileUtil.createDirectoriesSafe(this.folder); @@ -1052,7 +1090,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a this.regionCache.putAndMoveToFirst(key, ret); -@@ -119,7 +139,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -119,7 +144,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise } final ChunkPos pos = new ChunkPos(chunkX, chunkZ); @@ -1061,7 +1099,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a // note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input // (and, the regionfile parameter is unused for writing until the write call) -@@ -153,7 +173,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -153,7 +178,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise ) throws IOException { final ChunkPos pos = new ChunkPos(chunkX, chunkZ); if (writeData.result() == ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.DELETE) { @@ -1070,7 +1108,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a if (regionFile != null) { regionFile.clear(pos); } // else: didn't exist -@@ -168,7 +188,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -168,7 +193,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise public final ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.ReadData moonrise$readData( final int chunkX, final int chunkZ ) throws IOException { @@ -1079,7 +1117,16 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a final DataInputStream input = regionFile == null ? null : regionFile.getChunkDataInputStream(new ChunkPos(chunkX, chunkZ)); -@@ -250,12 +270,12 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -221,7 +246,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + @Nullable + public static ChunkPos getRegionFileCoordinates(Path file) { + String fileName = file.getFileName().toString(); +- if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) { ++ if (!fileName.startsWith("r.") || !fileName.endsWith(getExtensionName())) { // Luminol - Configurable region file format + return null; + } + +@@ -250,12 +275,12 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise } // Paper start - rewrite chunk system @@ -1094,7 +1141,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a // Paper start - rewrite chunk system if (existingOnly) { return this.moonrise$getRegionFileIfExists(chunkcoordintpair.x, chunkcoordintpair.z); -@@ -263,7 +283,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -263,7 +288,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise synchronized (this) { final long key = ChunkPos.asLong(chunkcoordintpair.x >> REGION_SHIFT, chunkcoordintpair.z >> REGION_SHIFT); @@ -1103,7 +1150,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a if (ret != null) { return ret; } -@@ -292,7 +312,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -292,7 +317,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER - You may ask for help on Discord, but do not file an issue. These error messages can not be removed."); } @@ -1112,7 +1159,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a synchronized (regionfile) { try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) { CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z); -@@ -327,7 +347,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -327,7 +352,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @Nullable public CompoundTag read(ChunkPos pos) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing @@ -1121,7 +1168,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a if (regionfile == null) { return null; } -@@ -391,7 +411,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -391,7 +416,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise public void scanChunk(ChunkPos chunkPos, StreamTagVisitor scanner) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing @@ -1130,7 +1177,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a if (regionfile == null) { return; } -@@ -421,7 +441,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -421,7 +446,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise } public void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { // Paper - rewrite chunk system - public @@ -1139,7 +1186,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a // Paper start - rewrite chunk system if (regionfile == null) { // if the RegionFile doesn't exist, no point in deleting from it -@@ -465,7 +485,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -465,7 +490,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise // Paper start - rewrite chunk system synchronized (this) { final ExceptionCollector exceptionCollector = new ExceptionCollector<>(); @@ -1148,7 +1195,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a try { regionFile.close(); } catch (final IOException ex) { -@@ -482,7 +502,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -482,7 +507,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise // Paper start - rewrite chunk system synchronized (this) { final ExceptionCollector exceptionCollector = new ExceptionCollector<>();