Push forward

This commit is contained in:
2026-07-14 12:22:17 +08:00
parent 576a9a44c8
commit 969cd5c5f8
135 changed files with 551 additions and 551 deletions
@@ -13,10 +13,10 @@ index a814512fcfb85312474ae2c2c21443843bf57831..5734af81b1f88fde952f498059c79116
public boolean moonrise$doesRegionFileNotExistNoIO(final int chunkX, final int chunkZ);
- public RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ);
+ public moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ); // Shiroha - Configurable region file format
+ public io.nanachiyo0721.shiroha.data.RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ); // Shiroha - Configurable region file format
- public RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException;
+ public moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException; // Shiroha - Configurable region file format
+ public io.nanachiyo0721.shiroha.data.RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException; // Shiroha - Configurable region file format
public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(
final int chunkX, final int chunkZ, final CompoundTag compound
@@ -29,7 +29,7 @@ index 3bb9b58ee97464687e348e23b99159226415c267..b6d4d9fac961aa4672ef2f4a19e2ae18
// Paper start - flush regionfiles on save
if (this.world.paperConfig().chunks.flushRegionsOnSave) {
- final RegionFile regionFile = this.regionDataController.getCache().moonrise$getRegionFileIfLoaded(this.chunkX, this.chunkZ);
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.regionDataController.getCache().moonrise$getRegionFileIfLoaded(this.chunkX, this.chunkZ); // Shiroha - Configurable region file format
+ final io.nanachiyo0721.shiroha.data.RegionFile regionFile = this.regionDataController.getCache().moonrise$getRegionFileIfLoaded(this.chunkX, this.chunkZ); // Shiroha - Configurable region file format
if (regionFile != null) {
regionFile.flush();
} // else: evicted from cache, which should have called flush
@@ -38,7 +38,7 @@ index 3bb9b58ee97464687e348e23b99159226415c267..b6d4d9fac961aa4672ef2f4a19e2ae18
public static interface IORunnable {
- public void run(final RegionFile regionFile) throws IOException;
+ public void run(final moe.monnairealms.camellia.data.RegionFile regionFile) throws IOException; // Shiroha - Configurable region file format
+ public void run(final io.nanachiyo0721.shiroha.data.RegionFile regionFile) throws IOException; // Shiroha - Configurable region file format
}
}
@@ -51,7 +51,7 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..084b64dbaa2807fa29e4ae787144fce2
public void moonrise$setWriteOnClose(final boolean value);
- public void moonrise$write(final RegionFile regionFile) throws IOException;
+ public void moonrise$write(final moe.monnairealms.camellia.data.RegionFile regionFile) throws IOException; // Shiroha - Configurable region file format
+ public void moonrise$write(final io.nanachiyo0721.shiroha.data.RegionFile regionFile) throws IOException; // Shiroha - Configurable region file format
}
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index e305fd5850d333eb1a30572076b6475e4428f7a7..78e9cf21fb5487e5eeec04e589c2a84c1e6b06af 100644
@@ -79,7 +79,7 @@ index a7f2cfa9277c898038f6b9e0a3401db51012b64c..d6151f308e2e5864b6525409761aa6d9
import net.minecraft.world.level.chunk.storage.RegionFile;
-public record FileToUpgrade(RegionFile file, List<ChunkPos> chunksToUpgrade) {
+public record FileToUpgrade(moe.monnairealms.camellia.data.RegionFile file, List<ChunkPos> chunksToUpgrade) { // Shiroha - Configurable region file format
+public record FileToUpgrade(io.nanachiyo0721.shiroha.data.RegionFile file, List<ChunkPos> chunksToUpgrade) { // Shiroha - Configurable region file format
}
diff --git a/net/minecraft/util/worldupdate/RegionStorageUpgrader.java b/net/minecraft/util/worldupdate/RegionStorageUpgrader.java
index b228cd6c54e8c8998923ab332882d99092769c67..13ec3d38ffb6e0e87db621c9607c9dc3c6a7b31b 100644
@@ -90,7 +90,7 @@ index b228cd6c54e8c8998923ab332882d99092769c67..13ec3d38ffb6e0e87db621c9607c9dc3
private static final Logger LOGGER = LogUtils.getLogger();
private static final String NEW_DIRECTORY_PREFIX = "new_";
- private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
+ private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\." + moe.monnairealms.camellia.config.modules.function.RegionFormatConfig.regionFormat.getArgument() + "$"); // Shiroha - Configurable region file format
+ private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\." + io.nanachiyo0721.shiroha.config.modules.function.RegionFormatConfig.regionFormat.getArgument() + "$"); // Shiroha - Configurable region file format
private final DataFixer dataFixer;
private final UpgradeProgress upgradeProgress;
private final String type;
@@ -99,8 +99,8 @@ index b228cd6c54e8c8998923ab332882d99092769c67..13ec3d38ffb6e0e87db621c9607c9dc3
List<ChunkPos> chunkPositions = Lists.newArrayList();
- try (RegionFile regionSource = new RegionFile(info, regionFile.toPath(), regionFolder, true)) {
+ var regionFileInfo = new moe.monnairealms.camellia.utils.RegionCreatorInfo(info, regionFile.toPath(), regionFolder, true); // Shiroha - Configurable region file format
+ try (moe.monnairealms.camellia.data.RegionFile regionSource = moe.monnairealms.camellia.config.modules.function.RegionFormatConfig.regionFormat.getCreator().newFile(regionFileInfo)) { // Shiroha - Configurable region file format
+ var regionFileInfo = new io.nanachiyo0721.shiroha.utils.RegionCreatorInfo(info, regionFile.toPath(), regionFolder, true); // Shiroha - Configurable region file format
+ try (io.nanachiyo0721.shiroha.data.RegionFile regionSource = io.nanachiyo0721.shiroha.config.modules.function.RegionFormatConfig.regionFormat.getCreator().newFile(regionFileInfo)) { // Shiroha - Configurable region file format
for (int x = 0; x < 32; x++) {
for (int z = 0; z < 32; z++) {
ChunkPos pos = new ChunkPos(x + xOffset, z + zOffset);
@@ -109,7 +109,7 @@ index b228cd6c54e8c8998923ab332882d99092769c67..13ec3d38ffb6e0e87db621c9607c9dc3
}
- private void onFileFinished(final RegionFile regionFile) {
+ private void onFileFinished(final moe.monnairealms.camellia.data.RegionFile regionFile) { // Shiroha - Configurable region file format
+ private void onFileFinished(final io.nanachiyo0721.shiroha.data.RegionFile regionFile) { // Shiroha - Configurable region file format
if (this.recreateRegionFiles) {
if (this.previousWriteFuture != null) {
this.previousWriteFuture.join();
@@ -122,7 +122,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..476aa2af20caeb8da293bd9e6c7467e3
import org.slf4j.Logger;
-public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile { // Paper - rewrite chunk system
+public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile , moe.monnairealms.camellia.data.RegionFile{ // Paper - rewrite chunk system // Shiroha - Configurable region file format
+public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile , io.nanachiyo0721.shiroha.data.RegionFile{ // Paper - rewrite chunk system // Shiroha - Configurable region file format
private static final Logger LOGGER = LogUtils.getLogger();
public static final int MAX_CHUNK_SIZE = 500 * 1024 * 1024; // Paper - don't write garbage data to disk if writing serialization fails
private static final int SECTOR_BYTES = 4096;
@@ -149,7 +149,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..476aa2af20caeb8da293bd9e6c7467e3
@Override
- public final void moonrise$write(final RegionFile regionFile) throws IOException {
+ public final void moonrise$write(final moe.monnairealms.camellia.data.RegionFile regionFile) throws IOException { // Shiroha - Configurable region file format
+ public final void moonrise$write(final io.nanachiyo0721.shiroha.data.RegionFile regionFile) throws IOException { // Shiroha - Configurable region file format
regionFile.write(this.pos, ByteBuffer.wrap(this.buf, 0, this.count));
}
// Paper end - rewrite chunk system
@@ -185,7 +185,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
public static final String ANVIL_EXTENSION = ".mca";
private static final int MAX_CACHE_SIZE = 256;
- private final Long2ObjectLinkedOpenHashMap<RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>();
+ private final Long2ObjectLinkedOpenHashMap<moe.monnairealms.camellia.data.RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>(); // Shiroha - Configurable region file format
+ private final Long2ObjectLinkedOpenHashMap<io.nanachiyo0721.shiroha.data.RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>(); // Shiroha - Configurable region file format
private final RegionStorageInfo info;
private final Path folder;
private final boolean sync;
@@ -206,8 +206,8 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
+ return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + getExtensionName(); // Shiroha - Configurable region file format
}
+ // Shiroha start - Configurable region file format
+ public static moe.monnairealms.camellia.data.RegionFile createNew(RegionStorageInfo info, Path filePath, Path folder, boolean sync) throws IOException{
+ final moe.monnairealms.camellia.enums.EnumRegionFormat regionFormat = moe.monnairealms.camellia.config.modules.function.RegionFormatConfig.regionFormat;
+ public static io.nanachiyo0721.shiroha.data.RegionFile createNew(RegionStorageInfo info, Path filePath, Path folder, boolean sync) throws IOException{
+ final io.nanachiyo0721.shiroha.enums.EnumRegionFormat regionFormat = io.nanachiyo0721.shiroha.config.modules.function.RegionFormatConfig.regionFormat;
+ final String fullFileName = filePath.getFileName().toString();
+ final String[] fullNameSplit = fullFileName.split("\\.");
+ final String extensionName = fullNameSplit[fullNameSplit.length - 1];
@@ -222,11 +222,11 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
+ throw new IOException("Invalid region file format: " + extensionName + " expected " + regionFormat.getArgument());
+ }
+
+ return regionFormat.getCreator().newFile(new moe.monnairealms.camellia.utils.RegionCreatorInfo(info, filePath, folder, sync));
+ return regionFormat.getCreator().newFile(new io.nanachiyo0721.shiroha.utils.RegionCreatorInfo(info, filePath, folder, sync));
+ }
+
+ public static String getExtensionName() {
+ return "." + moe.monnairealms.camellia.config.modules.function.RegionFormatConfig.regionFormat.getArgument();
+ return "." + io.nanachiyo0721.shiroha.config.modules.function.RegionFormatConfig.regionFormat.getArgument();
+ }
+ // Shiroha end
@@ -237,17 +237,17 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
@Override
- public synchronized final RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) {
+ public synchronized final moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) { // Shiroha - Configurable region file format
+ public synchronized final io.nanachiyo0721.shiroha.data.RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) { // Shiroha - Configurable region file format
return this.regionCache.getAndMoveToFirst(ChunkPos.pack(chunkX >> REGION_SHIFT, chunkZ >> REGION_SHIFT));
}
@Override
- public synchronized final RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException {
+ public synchronized final moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException { // Shiroha - Configurable region file format
+ public synchronized final io.nanachiyo0721.shiroha.data.RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException { // Shiroha - Configurable region file format
final long key = ChunkPos.pack(chunkX >> REGION_SHIFT, chunkZ >> REGION_SHIFT);
- RegionFile ret = this.regionCache.getAndMoveToFirst(key);
+ moe.monnairealms.camellia.data.RegionFile ret = this.regionCache.getAndMoveToFirst(key); // Shiroha - Configurable region file format
+ io.nanachiyo0721.shiroha.data.RegionFile ret = this.regionCache.getAndMoveToFirst(key); // Shiroha - Configurable region file format
if (ret != null) {
return ret;
}
@@ -265,7 +265,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
- final RegionFile regionFile = this.getRegionFile(pos);
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.getRegionFile(pos); // Shiroha - Configurable region file format
+ final io.nanachiyo0721.shiroha.data.RegionFile regionFile = this.getRegionFile(pos); // Shiroha - Configurable region file format
// 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)
@@ -274,7 +274,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
if (writeData.result() == ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.DELETE) {
- final RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ);
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Shiroha - Configurable region file format
+ final io.nanachiyo0721.shiroha.data.RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Shiroha - Configurable region file format
if (regionFile != null) {
regionFile.clear(pos);
} // else: didn't exist
@@ -283,7 +283,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
final int chunkX, final int chunkZ
) throws IOException {
- final RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ);
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Shiroha - Configurable region file format
+ final io.nanachiyo0721.shiroha.data.RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Shiroha - Configurable region file format
final DataInputStream input = regionFile == null ? null : regionFile.getChunkDataInputStream(new ChunkPos(chunkX, chunkZ));
@@ -292,7 +292,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
final ChunkPos headerChunkPos = SerializableChunkData.getChunkCoordinate(ret);
- final RegionFile regionFile = this.getRegionFile(pos);
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.getRegionFile(pos); // Shiroha - Configurable region file format
+ final io.nanachiyo0721.shiroha.data.RegionFile regionFile = this.getRegionFile(pos); // Shiroha - Configurable region file format
if (regionFile.getRecalculateCount() != readData.recalculateCount()) {
return null;
@@ -301,7 +301,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
// Paper end - rewrite chunk system
// Paper start - rewrite chunk system
- public RegionFile getRegionFile(ChunkPos pos) throws IOException {
+ public moe.monnairealms.camellia.data.RegionFile getRegionFile(ChunkPos pos) throws IOException { // Shiroha - Configurable region file format
+ public io.nanachiyo0721.shiroha.data.RegionFile getRegionFile(ChunkPos pos) throws IOException { // Shiroha - Configurable region file format
return this.getRegionFile(pos, false);
}
// Paper end - rewrite chunk system
@@ -310,7 +310,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
}
- @org.jetbrains.annotations.Contract("_, false -> !null") private @Nullable RegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit
+ @org.jetbrains.annotations.Contract("_, false -> !null") private moe.monnairealms.camellia.data.RegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit // Shiroha - Configurable region file format
+ @org.jetbrains.annotations.Contract("_, false -> !null") private io.nanachiyo0721.shiroha.data.RegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit // Shiroha - Configurable region file format
// Paper start - rewrite chunk system
if (existingOnly) {
return this.moonrise$getRegionFileIfExists(pos.x(), pos.z());
@@ -319,7 +319,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
final long key = ChunkPos.pack(pos.x() >> REGION_SHIFT, pos.z() >> REGION_SHIFT);
- RegionFile ret = this.regionCache.getAndMoveToFirst(key);
+ moe.monnairealms.camellia.data.RegionFile ret = this.regionCache.getAndMoveToFirst(key); // Shiroha - Configurable region file format
+ io.nanachiyo0721.shiroha.data.RegionFile ret = this.regionCache.getAndMoveToFirst(key); // Shiroha - Configurable region file format
if (ret != null) {
return ret;
}
@@ -337,7 +337,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
}
- private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException {
+ private static CompoundTag readOversizedChunk(moe.monnairealms.camellia.data.RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // Shiroha - Configurable region file format
+ private static CompoundTag readOversizedChunk(io.nanachiyo0721.shiroha.data.RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // Shiroha - Configurable region file format
synchronized (regionfile) {
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x(), chunkCoordinate.z());
@@ -346,7 +346,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
public @Nullable CompoundTag read(final ChunkPos pos) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
- RegionFile region = this.getRegionFile(pos, true);
+ moe.monnairealms.camellia.data.RegionFile region = this.getRegionFile(pos, true); // Shiroha - Configurable region file format
+ io.nanachiyo0721.shiroha.data.RegionFile region = this.getRegionFile(pos, true); // Shiroha - Configurable region file format
if (region == null) {
return null;
}
@@ -355,7 +355,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
public void scanChunk(final ChunkPos pos, final StreamTagVisitor scanner) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
- RegionFile region = this.getRegionFile(pos, true);
+ moe.monnairealms.camellia.data.RegionFile region = this.getRegionFile(pos, true); // Shiroha - Configurable region file format
+ io.nanachiyo0721.shiroha.data.RegionFile region = this.getRegionFile(pos, true); // Shiroha - Configurable region file format
if (region == null) {
return;
}
@@ -364,7 +364,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
public void write(final ChunkPos pos, final @Nullable CompoundTag value) throws IOException {
if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) {
- RegionFile region = this.getRegionFile(pos, value == null); // CraftBukkit // Paper - rewrite chunk system
+ moe.monnairealms.camellia.data.RegionFile region = this.getRegionFile(pos, value == null); // CraftBukkit // Paper - rewrite chunk system // Shiroha - Configurable region file format
+ io.nanachiyo0721.shiroha.data.RegionFile region = this.getRegionFile(pos, value == null); // CraftBukkit // Paper - rewrite chunk system // Shiroha - Configurable region file format
// Paper start - rewrite chunk system
if (region == null) {
// if the RegionFile doesn't exist, no point in deleting from it
@@ -373,7 +373,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
- for (final RegionFile regionFile : this.regionCache.values()) {
+ for (final moe.monnairealms.camellia.data.RegionFile regionFile : this.regionCache.values()) { // Shiroha - Configurable region file format
+ for (final io.nanachiyo0721.shiroha.data.RegionFile regionFile : this.regionCache.values()) { // Shiroha - Configurable region file format
try {
regionFile.close();
} catch (final IOException ex) {
@@ -382,7 +382,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
- for (final RegionFile regionFile : this.regionCache.values()) {
+ for (final moe.monnairealms.camellia.data.RegionFile regionFile : this.regionCache.values()) { // Shiroha - Configurable region file format
+ for (final io.nanachiyo0721.shiroha.data.RegionFile regionFile : this.regionCache.values()) { // Shiroha - Configurable region file format
try {
regionFile.flush();
} catch (final IOException ex) {