Skip to content

Commit 99c1675

Browse files
committed
Fix file extension
1 parent 2b5bedf commit 99c1675

File tree

1 file changed

+74
-27
lines changed

1 file changed

+74
-27
lines changed

patches/server/0018-Add-configurable-region-format-framework-linear-v2-r.patch

Lines changed: 74 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ index 0000000000000000000000000000000000000000..d92f1d549c7e01daa6b5bba7d405e462
6868
+}
6969
diff --git a/src/main/java/abomination/LinearRegionFile.java b/src/main/java/abomination/LinearRegionFile.java
7070
new file mode 100644
71-
index 0000000000000000000000000000000000000000..4b4a0f9b514909debf36e0937338f27eb2f99239
71+
index 0000000000000000000000000000000000000000..192572f2672b9afb8c593dbf96ba95225bf985dc
7272
--- /dev/null
7373
+++ b/src/main/java/abomination/LinearRegionFile.java
74-
@@ -0,0 +1,668 @@
74+
@@ -0,0 +1,666 @@
7575
+package abomination;
7676
+
7777
+import ca.spottedleaf.concurrentutil.executor.PrioritisedExecutor;
@@ -593,12 +593,10 @@ index 0000000000000000000000000000000000000000..4b4a0f9b514909debf36e0937338f27e
593593
+ final PrioritisedExecutor.PrioritisedTask created = linearIOExecutor.createTask(() -> {
594594
+ try {
595595
+ synchronized (this) {
596-
+ if (!this.isMarkedToSave() && !this.close) {
597-
+ return;
596+
+ if (!this.close) {
597+
+ this.flush();
598598
+ }
599599
+ }
600-
+
601-
+ this.flush();
602600
+ } catch (IOException e) {
603601
+ throw new RuntimeException(e);
604602
+ }
@@ -780,12 +778,24 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..c7d4d944eb198ac53a3eeae717a25c7d
780778
- public void moonrise$write(final RegionFile regionFile) throws IOException;
781779
+ public void moonrise$write(final abomination.IRegionFile regionFile) throws IOException; // Luminol - Configurable region file format
782780
}
781+
diff --git a/src/main/java/me/earthme/luminol/config/LuminolConfig.java b/src/main/java/me/earthme/luminol/config/LuminolConfig.java
782+
index 976cc572861174787b37992388a03ab01f8703a4..fcacd381e4a5875ed0c542a9e6c1804fae823435 100644
783+
--- a/src/main/java/me/earthme/luminol/config/LuminolConfig.java
784+
+++ b/src/main/java/me/earthme/luminol/config/LuminolConfig.java
785+
@@ -77,6 +77,7 @@ public class LuminolConfig {
786+
loadAllModules();
787+
}catch (Exception e){
788+
logger.error("Failed to load config modules!",e);
789+
+ throw new RuntimeException(e);
790+
}
791+
792+
configFileInstance.save();
783793
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
784794
new file mode 100644
785-
index 0000000000000000000000000000000000000000..d755934d41ed7cbcf26bc9f5682984a732edd18a
795+
index 0000000000000000000000000000000000000000..60546260cd1d535cc596485de2ced48b7e045b3a
786796
--- /dev/null
787797
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java
788-
@@ -0,0 +1,50 @@
798+
@@ -0,0 +1,48 @@
789799
+package me.earthme.luminol.config.modules.misc;
790800
+
791801
+import abomination.LinearRegionFile;
@@ -804,8 +814,6 @@ index 0000000000000000000000000000000000000000..d755934d41ed7cbcf26bc9f5682984a7
804814
+ public static int linearCompressionLevel = 1;
805815
+ @ConfigInfo(baseName = "linear_io_thread_count")
806816
+ public static int linearIoThreadCount = 6;
807-
+ @ConfigInfo(baseName = "linear_io_signal_check_delay_ms")
808-
+ public static int linearIoQueueSize = 100;
809817
+
810818
+ @DoNotLoad
811819
+ public static EnumRegionFormat regionFormat;
@@ -922,6 +930,28 @@ index 8cc0c01a19fc71753d7c3ed4fa7e9992aaf93b5a..88be8a6232bc3311cc0bdb7c697f7a78
922930
// Folia start - region threading
923931
this.stopPart2();
924932
}
933+
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
934+
index 622d0cbe023774d92d212f242b60b96317720835..b34b2519a2abccd1d60edb7a89cb080541df18d0 100644
935+
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
936+
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
937+
@@ -75,7 +75,7 @@ public class WorldUpgrader implements AutoCloseable {
938+
volatile int skipped;
939+
final Reference2FloatMap<ResourceKey<Level>> progressMap = Reference2FloatMaps.synchronize(new Reference2FloatOpenHashMap());
940+
volatile Component status = Component.translatable("optimizeWorld.stage.counting");
941+
- static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
942+
+ static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\\\"+ net.minecraft.world.level.chunk.storage.RegionFileStorage.getExtensionName() +"$"); // Luminol - Configurable region file format
943+
final DimensionDataStorage overworldDataStorage;
944+
945+
public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, RegistryAccess dynamicRegistryManager, boolean eraseCache, boolean recreateRegionFiles) {
946+
@@ -399,7 +399,7 @@ public class WorldUpgrader implements AutoCloseable {
947+
948+
private static List<WorldUpgrader.FileToUpgrade> getAllChunkPositions(RegionStorageInfo key, Path regionDirectory) {
949+
File[] afile = regionDirectory.toFile().listFiles((file, s) -> {
950+
- return s.endsWith(".mca");
951+
+ return s.endsWith(net.minecraft.world.level.chunk.storage.RegionFileStorage.getExtensionName()); // Luminol - Configurable region file format
952+
});
953+
954+
if (afile == null) {
925955
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
926956
index 16f07007a0f73ec0c6f421c9b082518e87e8cc7b..fc69834e18e0860750d878e1361722fc38b513f8 100644
927957
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -985,7 +1015,7 @@ index 16f07007a0f73ec0c6f421c9b082518e87e8cc7b..fc69834e18e0860750d878e1361722fc
9851015
}
9861016
// Paper end - rewrite chunk system
9871017
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
988-
index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a09ff02da 100644
1018+
index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9fcf450d0c 100644
9891019
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
9901020
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
9911021
@@ -23,7 +23,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -997,9 +1027,12 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
9971027
private final RegionStorageInfo info;
9981028
private final Path folder;
9991029
private final boolean sync;
1000-
@@ -35,6 +35,26 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1030+
@@ -33,8 +33,33 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1031+
private static final int MAX_NON_EXISTING_CACHE = 1024 * 4;
1032+
private final it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet nonExistingRegionFiles = new it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet();
10011033
private static String getRegionFileName(final int chunkX, final int chunkZ) {
1002-
return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + ".mca";
1034+
- return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + ".mca";
1035+
+ return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + getExtensionName(); // Luminol - Configurable region file format
10031036
}
10041037
+ // Luminol start - Configurable region file format
10051038
+ protected abomination.IRegionFile createNew(RegionStorageInfo info, Path filePath, Path folder, boolean sync) throws IOException{
@@ -1015,16 +1048,21 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
10151048
+ }
10161049
+
10171050
+ if (!regionFormat.getArgument().equalsIgnoreCase(argument)) {
1018-
+ throw new IOException("Invalid region file format: " + argument + " expected " + regionFormat.getArgument());
1051+
+ net.minecraft.server.MinecraftServer.setFatalException(new RuntimeException("Invalid region file format: " + argument + " expected " + regionFormat.getArgument()));
1052+
+ throw new IOException("Invalid region file format: ." + argument + " expected " + regionFormat.getArgument());
10191053
+ }
10201054
+
10211055
+ return regionFormat.getCreator().create(new me.earthme.luminol.utils.RegionCreatorInfo(info, filePath, folder, sync));
10221056
+ }
1057+
+
1058+
+ public static String getExtensionName() {
1059+
+ return me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormat.getArgument();
1060+
+ }
10231061
+ // Luminol end
10241062

10251063
private boolean doesRegionFilePossiblyExist(final long position) {
10261064
synchronized (this.nonExistingRegionFiles) {
1027-
@@ -68,15 +88,15 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1065+
@@ -68,15 +93,15 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
10281066
}
10291067

10301068
@Override
@@ -1043,7 +1081,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
10431081
if (ret != null) {
10441082
return ret;
10451083
}
1046-
@@ -100,7 +120,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1084+
@@ -100,7 +125,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
10471085

10481086
FileUtil.createDirectoriesSafe(this.folder);
10491087

@@ -1052,7 +1090,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
10521090

10531091
this.regionCache.putAndMoveToFirst(key, ret);
10541092

1055-
@@ -119,7 +139,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1093+
@@ -119,7 +144,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
10561094
}
10571095

10581096
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
@@ -1061,7 +1099,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
10611099

10621100
// note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input
10631101
// (and, the regionfile parameter is unused for writing until the write call)
1064-
@@ -153,7 +173,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1102+
@@ -153,7 +178,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
10651103
) throws IOException {
10661104
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
10671105
if (writeData.result() == ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.DELETE) {
@@ -1070,7 +1108,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
10701108
if (regionFile != null) {
10711109
regionFile.clear(pos);
10721110
} // else: didn't exist
1073-
@@ -168,7 +188,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1111+
@@ -168,7 +193,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
10741112
public final ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.ReadData moonrise$readData(
10751113
final int chunkX, final int chunkZ
10761114
) throws IOException {
@@ -1079,7 +1117,16 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
10791117

10801118
final DataInputStream input = regionFile == null ? null : regionFile.getChunkDataInputStream(new ChunkPos(chunkX, chunkZ));
10811119

1082-
@@ -250,12 +270,12 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1120+
@@ -221,7 +246,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1121+
@Nullable
1122+
public static ChunkPos getRegionFileCoordinates(Path file) {
1123+
String fileName = file.getFileName().toString();
1124+
- if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
1125+
+ if (!fileName.startsWith("r.") || !fileName.endsWith(getExtensionName())) { // Luminol - Configurable region file format
1126+
return null;
1127+
}
1128+
1129+
@@ -250,12 +275,12 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
10831130
}
10841131

10851132
// Paper start - rewrite chunk system
@@ -1094,7 +1141,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
10941141
// Paper start - rewrite chunk system
10951142
if (existingOnly) {
10961143
return this.moonrise$getRegionFileIfExists(chunkcoordintpair.x, chunkcoordintpair.z);
1097-
@@ -263,7 +283,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1144+
@@ -263,7 +288,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
10981145
synchronized (this) {
10991146
final long key = ChunkPos.asLong(chunkcoordintpair.x >> REGION_SHIFT, chunkcoordintpair.z >> REGION_SHIFT);
11001147

@@ -1103,7 +1150,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
11031150
if (ret != null) {
11041151
return ret;
11051152
}
1106-
@@ -292,7 +312,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1153+
@@ -292,7 +317,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
11071154
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.");
11081155
}
11091156

@@ -1112,7 +1159,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
11121159
synchronized (regionfile) {
11131160
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
11141161
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
1115-
@@ -327,7 +347,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1162+
@@ -327,7 +352,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
11161163
@Nullable
11171164
public CompoundTag read(ChunkPos pos) throws IOException {
11181165
// 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
11211168
if (regionfile == null) {
11221169
return null;
11231170
}
1124-
@@ -391,7 +411,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1171+
@@ -391,7 +416,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
11251172

11261173
public void scanChunk(ChunkPos chunkPos, StreamTagVisitor scanner) throws IOException {
11271174
// 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
11301177
if (regionfile == null) {
11311178
return;
11321179
}
1133-
@@ -421,7 +441,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1180+
@@ -421,7 +446,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
11341181
}
11351182

11361183
public void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { // Paper - rewrite chunk system - public
@@ -1139,7 +1186,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
11391186
// Paper start - rewrite chunk system
11401187
if (regionfile == null) {
11411188
// if the RegionFile doesn't exist, no point in deleting from it
1142-
@@ -465,7 +485,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1189+
@@ -465,7 +490,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
11431190
// Paper start - rewrite chunk system
11441191
synchronized (this) {
11451192
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
@@ -1148,7 +1195,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
11481195
try {
11491196
regionFile.close();
11501197
} catch (final IOException ex) {
1151-
@@ -482,7 +502,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
1198+
@@ -482,7 +507,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
11521199
// Paper start - rewrite chunk system
11531200
synchronized (this) {
11541201
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();

0 commit comments

Comments
 (0)