@@ -68,10 +68,10 @@ index 0000000000000000000000000000000000000000..d92f1d549c7e01daa6b5bba7d405e462
68
68
+ }
69
69
diff --git a/src/main/java/abomination/LinearRegionFile.java b/src/main/java/abomination/LinearRegionFile.java
70
70
new file mode 100644
71
- index 0000000000000000000000000000000000000000..4b4a0f9b514909debf36e0937338f27eb2f99239
71
+ index 0000000000000000000000000000000000000000..192572f2672b9afb8c593dbf96ba95225bf985dc
72
72
--- /dev/null
73
73
+++ b/src/main/java/abomination/LinearRegionFile.java
74
- @@ -0,0 +1,668 @@
74
+ @@ -0,0 +1,666 @@
75
75
+ package abomination;
76
76
+
77
77
+ import ca.spottedleaf.concurrentutil.executor.PrioritisedExecutor;
@@ -593,12 +593,10 @@ index 0000000000000000000000000000000000000000..4b4a0f9b514909debf36e0937338f27e
593
593
+ final PrioritisedExecutor.PrioritisedTask created = linearIOExecutor.createTask(() -> {
594
594
+ try {
595
595
+ synchronized (this) {
596
- + if (!this.isMarkedToSave() && !this. close) {
597
- + return ;
596
+ + if (!this.close) {
597
+ + this.flush() ;
598
598
+ }
599
599
+ }
600
- +
601
- + this.flush();
602
600
+ } catch (IOException e) {
603
601
+ throw new RuntimeException(e);
604
602
+ }
@@ -780,12 +778,24 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..c7d4d944eb198ac53a3eeae717a25c7d
780
778
- public void moonrise$write(final RegionFile regionFile) throws IOException;
781
779
+ public void moonrise$write(final abomination.IRegionFile regionFile) throws IOException; // Luminol - Configurable region file format
782
780
}
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();
783
793
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
784
794
new file mode 100644
785
- index 0000000000000000000000000000000000000000..d755934d41ed7cbcf26bc9f5682984a732edd18a
795
+ index 0000000000000000000000000000000000000000..60546260cd1d535cc596485de2ced48b7e045b3a
786
796
--- /dev/null
787
797
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java
788
- @@ -0,0 +1,50 @@
798
+ @@ -0,0 +1,48 @@
789
799
+ package me.earthme.luminol.config.modules.misc;
790
800
+
791
801
+ import abomination.LinearRegionFile;
@@ -804,8 +814,6 @@ index 0000000000000000000000000000000000000000..d755934d41ed7cbcf26bc9f5682984a7
804
814
+ public static int linearCompressionLevel = 1;
805
815
+ @ConfigInfo(baseName = "linear_io_thread_count")
806
816
+ public static int linearIoThreadCount = 6;
807
- + @ConfigInfo(baseName = "linear_io_signal_check_delay_ms")
808
- + public static int linearIoQueueSize = 100;
809
817
+
810
818
+ @DoNotLoad
811
819
+ public static EnumRegionFormat regionFormat;
@@ -922,6 +930,28 @@ index 8cc0c01a19fc71753d7c3ed4fa7e9992aaf93b5a..88be8a6232bc3311cc0bdb7c697f7a78
922
930
// Folia start - region threading
923
931
this.stopPart2();
924
932
}
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) {
925
955
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
926
956
index 16f07007a0f73ec0c6f421c9b082518e87e8cc7b..fc69834e18e0860750d878e1361722fc38b513f8 100644
927
957
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -985,7 +1015,7 @@ index 16f07007a0f73ec0c6f421c9b082518e87e8cc7b..fc69834e18e0860750d878e1361722fc
985
1015
}
986
1016
// Paper end - rewrite chunk system
987
1017
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
989
1019
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
990
1020
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
991
1021
@@ -23,7 +23,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -997,9 +1027,12 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
997
1027
private final RegionStorageInfo info;
998
1028
private final Path folder;
999
1029
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();
1001
1033
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
1003
1036
}
1004
1037
+ // Luminol start - Configurable region file format
1005
1038
+ protected abomination.IRegionFile createNew(RegionStorageInfo info, Path filePath, Path folder, boolean sync) throws IOException{
@@ -1015,16 +1048,21 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1015
1048
+ }
1016
1049
+
1017
1050
+ 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());
1019
1053
+ }
1020
1054
+
1021
1055
+ return regionFormat.getCreator().create(new me.earthme.luminol.utils.RegionCreatorInfo(info, filePath, folder, sync));
1022
1056
+ }
1057
+ +
1058
+ + public static String getExtensionName() {
1059
+ + return me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormat.getArgument();
1060
+ + }
1023
1061
+ // Luminol end
1024
1062
1025
1063
private boolean doesRegionFilePossiblyExist(final long position) {
1026
1064
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
1028
1066
}
1029
1067
1030
1068
@Override
@@ -1043,7 +1081,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1043
1081
if (ret != null) {
1044
1082
return ret;
1045
1083
}
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
1047
1085
1048
1086
FileUtil.createDirectoriesSafe(this.folder);
1049
1087
@@ -1052,7 +1090,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1052
1090
1053
1091
this.regionCache.putAndMoveToFirst(key, ret);
1054
1092
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
1056
1094
}
1057
1095
1058
1096
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
@@ -1061,7 +1099,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1061
1099
1062
1100
// note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input
1063
1101
// (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
1065
1103
) throws IOException {
1066
1104
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
1067
1105
if (writeData.result() == ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.DELETE) {
@@ -1070,7 +1108,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1070
1108
if (regionFile != null) {
1071
1109
regionFile.clear(pos);
1072
1110
} // 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
1074
1112
public final ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.ReadData moonrise$readData(
1075
1113
final int chunkX, final int chunkZ
1076
1114
) throws IOException {
@@ -1079,7 +1117,16 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1079
1117
1080
1118
final DataInputStream input = regionFile == null ? null : regionFile.getChunkDataInputStream(new ChunkPos(chunkX, chunkZ));
1081
1119
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
1083
1130
}
1084
1131
1085
1132
// Paper start - rewrite chunk system
@@ -1094,7 +1141,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1094
1141
// Paper start - rewrite chunk system
1095
1142
if (existingOnly) {
1096
1143
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
1098
1145
synchronized (this) {
1099
1146
final long key = ChunkPos.asLong(chunkcoordintpair.x >> REGION_SHIFT, chunkcoordintpair.z >> REGION_SHIFT);
1100
1147
@@ -1103,7 +1150,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1103
1150
if (ret != null) {
1104
1151
return ret;
1105
1152
}
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
1107
1154
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.");
1108
1155
}
1109
1156
@@ -1112,7 +1159,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1112
1159
synchronized (regionfile) {
1113
1160
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
1114
1161
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
1116
1163
@Nullable
1117
1164
public CompoundTag read(ChunkPos pos) throws IOException {
1118
1165
// 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
1121
1168
if (regionfile == null) {
1122
1169
return null;
1123
1170
}
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
1125
1172
1126
1173
public void scanChunk(ChunkPos chunkPos, StreamTagVisitor scanner) throws IOException {
1127
1174
// 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
1130
1177
if (regionfile == null) {
1131
1178
return;
1132
1179
}
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
1134
1181
}
1135
1182
1136
1183
public void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { // Paper - rewrite chunk system - public
@@ -1139,7 +1186,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1139
1186
// Paper start - rewrite chunk system
1140
1187
if (regionfile == null) {
1141
1188
// 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
1143
1190
// Paper start - rewrite chunk system
1144
1191
synchronized (this) {
1145
1192
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
@@ -1148,7 +1195,7 @@ index e40665cead218502b44dd49051a53326ed94f061..c9371ef5123df1c343d6e8dccad7347a
1148
1195
try {
1149
1196
regionFile.close();
1150
1197
} 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
1152
1199
// Paper start - rewrite chunk system
1153
1200
synchronized (this) {
1154
1201
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
0 commit comments