Compare commits

...

18 Commits

Author SHA1 Message Date
Sofiane H. Djerbi
ac5e38e86e Linear file format rework / Per world file format / Polyglot server
- Per world region format settings
- Polyglot: server can read both ANVIL and LINEAR files at the same time, and save using format specified in config
2023-03-05 18:59:58 +01:00
Sofiane H. Djerbi
dbbc862af3 Polyglot server 2023-03-05 19:49:45 +02:00
Sofiane H. Djerbi
784e2baf7a Per world region file format 2023-03-04 09:42:46 +02:00
Sofiane H. Djerbi
94ca13f790 Merge pull request #17 from KaiijuMC/update-upstream
Update Upstream (Purpur)
2023-02-27 18:44:44 +01:00
kugge
963286ac7e Update Upstream (Purpur) 2023-02-27 15:18:38 +00:00
Sofiane H. Djerbi
0383ff6961 Release on push 2023-02-26 23:22:35 +01:00
Sofiane H. Djerbi
8e1bfd6c3c Merge pull request #16 from KaiijuMC/update-upstream
Update Upstream (Purpur)
2023-02-26 23:21:40 +01:00
kugge
1638fe6b97 Update Upstream (Purpur) 2023-02-26 15:17:34 +00:00
Sofiane H. Djerbi
d5699419e4 Merge pull request #14 from KaiijuMC/update-upstream
Update Upstream (Purpur)
2023-02-25 01:17:25 +01:00
kugge
d57758c9f8 Update Upstream (Purpur) 2023-02-23 15:13:37 +00:00
Sofiane H. Djerbi
63d893a0e4 Merge pull request #12 from KaiijuMC/update-upstream
Update Upstream (Purpur)
2023-02-22 23:15:01 +01:00
kugge
08892016f5 Update Upstream (Purpur) 2023-02-22 15:14:39 +00:00
Sofiane H. Djerbi
32ac7246a3 Quick refactoring 2023-02-22 00:52:27 +02:00
Sofiane H. Djerbi
4caf0ff2bd Update README.md 2023-02-21 23:47:54 +01:00
Sofiane H. Djerbi
d4ca1a3765 Merge pull request #10 from KaiijuMC/update-upstream
Update Upstream (Purpur)
2023-02-21 23:37:10 +01:00
kugge
842d7fa834 Update Upstream (Purpur) 2023-02-21 15:13:38 +00:00
Sofiane H. Djerbi
ecad700a9e Merge pull request #9 from KaiijuMC/update-upstream
Update Upstream (Purpur)
2023-02-20 16:40:44 +01:00
kugge
1190cfc22a Update Upstream (Purpur) 2023-02-20 15:13:51 +00:00
14 changed files with 322 additions and 192 deletions

View File

@@ -1,5 +1,5 @@
name: Release Jars
on: workflow_dispatch
on: [push, workflow_dispatch]
env:
version: '1.19.3'
branch: ver/1.19.3

View File

@@ -17,6 +17,11 @@
- **Xymb Linear Format**: Saves about 50% of disk space in OW and Nether and 95% in The End.
- **Lobotomize**: Lobotomize mobs and villagers without breaking vanilla mechanics.
### Roadmap
- **Lithium**: Full implementation of Lithium.
- **C2ME**: Full implementation of C2ME.
- **VMP**: Full implementation of VMP.
## Building
In order to distribute and use this server software, you need a paperclip file:

View File

@@ -2,7 +2,7 @@ group = dev.kaiijumc.kaiiju
version = 1.19.3-R0.1-SNAPSHOT
mcVersion = 1.19.3
purpurRef = 41593baf70c5402c2ad39e867b0f89561af95c30
purpurRef = afcd5b6f10fefa0e8599fd5ec08ec850912bac76
org.gradle.caching=true
org.gradle.parallel=true

View File

@@ -453,10 +453,10 @@ index a9289072b048095330ea32d7c965e8dda61a36fc..bffd82b3d89e12f2c3d6a7e89f5a8ecd
this.generator = gen;
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1b65a38fd65f420f79bbd4c2f6c53e3d9b2d8f81..12e4fb8d9e085991c54a78849e8492e47ba194ed 100644
index 2132954c6e8a32b33bb6b19344db047c32f109cc..fb690144143e6f23ca4064d84e6e0bbad059ceb5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1033,6 +1033,7 @@ public final class CraftServer implements Server {
@@ -977,6 +977,7 @@ public final class CraftServer implements Server {
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
this.console.paperConfigurations.reloadConfigs(this.console);
org.purpurmc.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur
@@ -464,7 +464,7 @@ index 1b65a38fd65f420f79bbd4c2f6c53e3d9b2d8f81..12e4fb8d9e085991c54a78849e8492e4
for (ServerLevel world : this.console.getAllLevels()) {
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
@@ -1049,6 +1050,7 @@ public final class CraftServer implements Server {
@@ -993,6 +994,7 @@ public final class CraftServer implements Server {
}
world.spigotConfig.init(); // Spigot
world.purpurConfig.init(); // Purpur
@@ -472,7 +472,7 @@ index 1b65a38fd65f420f79bbd4c2f6c53e3d9b2d8f81..12e4fb8d9e085991c54a78849e8492e4
}
Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper
@@ -1065,6 +1067,7 @@ public final class CraftServer implements Server {
@@ -1009,6 +1011,7 @@ public final class CraftServer implements Server {
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
org.purpurmc.purpur.PurpurConfig.registerCommands(); // Purpur
@@ -480,7 +480,7 @@ index 1b65a38fd65f420f79bbd4c2f6c53e3d9b2d8f81..12e4fb8d9e085991c54a78849e8492e4
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
@@ -2886,6 +2889,13 @@ public final class CraftServer implements Server {
@@ -2831,6 +2834,13 @@ public final class CraftServer implements Server {
}
// Purpur end

View File

@@ -4,27 +4,47 @@ Date: Fri, 10 Feb 2023 20:03:58 +0200
Subject: [PATCH] Kaiiju RegionFormat Configuration
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027..09fb7dcc56d5e266c8a1719c696653f644e0cfc1 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -192,4 +192,16 @@ public class KaiijuConfig {
}
return builder.build();
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19..b194f4dbebcbbf5bb4e026a0169e2d24806b46ec 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -4,9 +4,11 @@ import org.apache.commons.lang.BooleanUtils;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
+import java.util.logging.Level;
import static dev.kaiijumc.kaiiju.KaiijuConfig.log;
@@ -122,4 +124,23 @@ public class KaiijuWorldConfig {
final Map<String, Object> value = getMap("world-settings." + worldName + "." + path, null);
return value.isEmpty() ? fallback : value;
}
+
+ public static List<String> regionFormatList = Arrays.asList("ANVIL");
+ public static String regionFormatName = "ANVIL";
+ public List<String> regionFormatList = Arrays.asList("ANVIL", "LINEAR");
+ public String regionFormatName = "ANVIL";
+ public int regionFormatLinearCompressionLevel = 1;
+
+ private static void regionFormatSettings() {
+ private void regionFormatSettings() {
+ regionFormatName = getString("region-format.format", regionFormatName).toUpperCase();
+ if (!regionFormatList.contains(regionFormatName)) {
+ Bukkit.getLogger().log(Level.SEVERE, "Unknown region format in kaiiju.yml: " + regionFormatName);
+ Bukkit.getLogger().log(Level.SEVERE, "Falling back to ANVIL region file format.");
+ log(Level.SEVERE, "Unknown region format in kaiiju.yml: " + regionFormatName);
+ log(Level.SEVERE, "Falling back to ANVIL region file format.");
+ regionFormatName = "ANVIL";
+ }
+ regionFormatLinearCompressionLevel = getInt("region-format.linear.compression-level", regionFormatLinearCompressionLevel);
+ if (regionFormatLinearCompressionLevel > 23 || regionFormatLinearCompressionLevel < 1) {
+ log(Level.SEVERE, "Linear region compression level should be between 1 and 22 in kaiiju.yml: " + regionFormatLinearCompressionLevel);
+ log(Level.SEVERE, "Falling back to compression level 1.");
+ regionFormatLinearCompressionLevel = 1;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 40b4bd2f1a61c2d9a59c9c09b72713401969460b..b9998c288c4e8b6a244722915e44250b6550fd7e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java

View File

@@ -37,39 +37,12 @@ index f2c27e0ac65be4b75c1d86ef6fd45fdb538d96ac..00724993d0448454d14a47652b039b88
public static final class InProgressWrite {
public long writeCounter;
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 09fb7dcc56d5e266c8a1719c696653f644e0cfc1..2ae67b36a08688c3041635c2db04b05e295c4eea 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -193,8 +193,9 @@ public class KaiijuConfig {
return builder.build();
}
- public static List<String> regionFormatList = Arrays.asList("ANVIL");
+ public static List<String> regionFormatList = Arrays.asList("ANVIL", "LINEAR");
public static String regionFormatName = "ANVIL";
+ public static int regionFormatLinearCompressionLevel = 1;
private static void regionFormatSettings() {
regionFormatName = getString("region-format.format", regionFormatName).toUpperCase();
@@ -203,5 +204,11 @@ public class KaiijuConfig {
Bukkit.getLogger().log(Level.SEVERE, "Falling back to ANVIL region file format.");
regionFormatName = "ANVIL";
}
+ regionFormatLinearCompressionLevel = getInt("region-format.linear.compression-level", regionFormatLinearCompressionLevel);
+ if (regionFormatLinearCompressionLevel > 23 || regionFormatLinearCompressionLevel < 1) {
+ Bukkit.getLogger().log(Level.SEVERE, "Linear region compression level should be between 1 and 22 in kaiiju.yml: " + regionFormatLinearCompressionLevel);
+ Bukkit.getLogger().log(Level.SEVERE, "Falling back to compression level 1.");
+ regionFormatLinearCompressionLevel = 1;
+ }
}
}
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..70d53d80f474eb80acc93275ad6bf1da98ea8ae7
index 0000000000000000000000000000000000000000..249303116d3cfadd078ebf0ae6e44bf99eed6a47
--- /dev/null
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java
@@ -0,0 +1,32 @@
@@ -0,0 +1,31 @@
+package dev.kaiijumc.kaiiju.region;
+
+import net.minecraft.nbt.CompoundTag;
@@ -83,31 +56,30 @@ index 0000000000000000000000000000000000000000..70d53d80f474eb80acc93275ad6bf1da
+import java.util.concurrent.locks.ReentrantLock;
+
+public interface AbstractRegionFile {
+ boolean doesChunkExist(ChunkPos pos) throws Exception;
+ void flush() throws IOException;
+ void setStatus(int x, int z, ChunkStatus status);
+ void clear(ChunkPos pos) throws IOException;
+ boolean hasChunk(ChunkPos pos);
+ void close() throws IOException;
+ void setStatus(int x, int z, ChunkStatus status);
+ void setOversized(int x, int z, boolean b) throws IOException;
+
+ boolean hasChunk(ChunkPos pos);
+ boolean doesChunkExist(ChunkPos pos) throws Exception;
+ boolean isOversized(int x, int z);
+ boolean recalculateHeader() throws IOException;
+
+ DataOutputStream getChunkDataOutputStream(ChunkPos pos) throws IOException;
+ DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException;
+ ChunkStatus getStatusIfCached(int x, int z);
+
+ Path getRegionFile();
+ ReentrantLock getFileLock();
+
+ void setOversized(int x, int z, boolean b) throws IOException;
+ CompoundTag getOversizedData(int x, int z) throws IOException;
+ boolean isOversized(int x, int z);
+ boolean recalculateHeader() throws IOException;
+ ChunkStatus getStatusIfCached(int x, int z);
+ ReentrantLock getFileLock();
+ Path getRegionFile();
+}
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFileFactory.java b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFileFactory.java
new file mode 100644
index 0000000000000000000000000000000000000000..0b84b1aa4b822bdcb783285e8ea99a4f25dbbaa3
index 0000000000000000000000000000000000000000..a470609b107f46ffc3bb7b121525ca8b803b4322
--- /dev/null
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFileFactory.java
@@ -0,0 +1,38 @@
@@ -0,0 +1,46 @@
+package dev.kaiijumc.kaiiju.region;
+
+import net.minecraft.world.level.chunk.storage.RegionFile;
@@ -126,21 +98,29 @@ index 0000000000000000000000000000000000000000..0b84b1aa4b822bdcb783285e8ea99a4f
+ return getAbstractRegionFile(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader);
+ }
+
+ public static AbstractRegionFile getAbstractRegionFile(File file, File directory, boolean dsync) throws IOException {
+ return getAbstractRegionFile(file.toPath(), directory.toPath(), RegionFileVersion.VERSION_DEFLATE, dsync);
+ }
+
+ public static AbstractRegionFile getAbstractRegionFile(File file, File directory, boolean dsync, boolean canRecalcHeader) throws IOException {
+ return getAbstractRegionFile(file.toPath(), directory.toPath(), RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader);
+ }
+
+ public static AbstractRegionFile getAbstractRegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException {
+ return getAbstractRegionFile(file, directory, outputChunkStreamVersion, dsync, false);
+ }
+
+ public static AbstractRegionFile getAbstractRegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
+ return new LinearRegionFile(file, directory, outputChunkStreamVersion, dsync, canRecalcHeader);
+ return getAbstractRegionFile(1, file, directory, outputChunkStreamVersion, dsync, canRecalcHeader);
+ }
+
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, boolean dsync) throws IOException {
+ return getAbstractRegionFile(linearCompression, file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);
+ }
+
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, boolean dsync, boolean canRecalcHeader) throws IOException {
+ return getAbstractRegionFile(linearCompression, file, directory, RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader);
+ }
+
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException {
+ return getAbstractRegionFile(linearCompression, file, directory, outputChunkStreamVersion, dsync, false);
+ }
+
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException {
+ if (file.toString().endsWith(".linear")) {
+ return new LinearRegionFile(file, linearCompression);
+ } else {
+ return new RegionFile(file, directory, outputChunkStreamVersion, dsync, canRecalcHeader);
+ }
@@ -148,10 +128,10 @@ index 0000000000000000000000000000000000000000..0b84b1aa4b822bdcb783285e8ea99a4f
+}
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd493de2fcf5
index 0000000000000000000000000000000000000000..2e0d10ded886e82c09700a1c6602cd1bb9d1967e
--- /dev/null
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
@@ -0,0 +1,339 @@
@@ -0,0 +1,342 @@
+package dev.kaiijumc.kaiiju.region;
+
+import com.github.luben.zstd.ZstdInputStream;
@@ -165,7 +145,6 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.world.level.ChunkPos;
+import net.minecraft.world.level.chunk.ChunkStatus;
+import net.minecraft.world.level.chunk.storage.RegionFileVersion;
+import org.slf4j.Logger;
+
+import javax.annotation.Nullable;
@@ -182,13 +161,16 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ private final byte[][] buffer = new byte[32*32][];
+ private final int[] bufferUncompressedSize = new int[32*32];
+
+ private final ChunkStatus[] statuses = new ChunkStatus[32 * 32];
+ private boolean markedToSave = false;
+ private final Object markedToSaveLock = new Object();
+ private final ChunkStatus[] statuses = new ChunkStatus[32 * 32];
+
+ private boolean markedToSave = false;
+ private boolean close = false;
+ public Path regionFile;
+
+ public final ReentrantLock fileLock = new ReentrantLock(true);
+ final int COMPRESSION_LEVEL = KaiijuConfig.regionFormatLinearCompressionLevel;
+ public Path regionFile;
+
+ private final int compressionLevel;
+
+ public Path getRegionFile() {
+ return this.regionFile;
@@ -198,13 +180,14 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ return this.fileLock;
+ }
+
+ public LinearRegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException {
+ public LinearRegionFile(Path file, int compression) throws IOException {
+ this.regionFile = file;
+ this.compressionLevel = compression;
+ File regionFile = new File(this.regionFile.toString());
+
+ LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
+
+ for (int i = 0 ; i < 32 * 32 ; i++)
+ for (int i = 0; i < 32 * 32; i++)
+ this.bufferUncompressedSize[i] = 0;
+
+ if(regionFile.canRead()) {
@@ -220,7 +203,7 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ long superBlock = rawDataStream.readLong();
+
+ if (superBlock != SUPERBLOCK) {
+ System.out.println(file.toString());
+ System.out.println(file);
+ System.out.println("SUPERBLOCK INVALID!");
+ return;
+ }
@@ -228,7 +211,7 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ byte version = rawDataStream.readByte();
+
+ if (version != VERSION) {
+ System.out.println(file.toString());
+ System.out.println(file);
+ System.out.println("VERSION INVALID!");
+ return;
+ }
@@ -239,7 +222,7 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ int dataCount = rawDataStream.readInt();
+
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE) {
+ throw new IOException("File length invalid " + this.regionFile + " " + String.valueOf(fileLength) + " " + String.valueOf(HEADER_SIZE + dataCount + FOOTER_SIZE));
+ throw new IOException("File length invalid " + this.regionFile + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
+ }
+
+ rawDataStream.readLong(); // Data Hash
@@ -334,7 +317,7 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ FileOutputStream fileStream = new FileOutputStream(tempFile);
+
+ ByteArrayOutputStream zstdByteArray = new ByteArrayOutputStream();
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, COMPRESSION_LEVEL);
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, this.compressionLevel);
+ zstdStream.setChecksum(true);
+ DataOutputStream zstdDataStream = new DataOutputStream(zstdStream);
+ DataOutputStream dataStream = new DataOutputStream(fileStream);
@@ -342,11 +325,11 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ dataStream.writeLong(SUPERBLOCK);
+ dataStream.writeByte(VERSION);
+ dataStream.writeLong(timestamp);
+ dataStream.writeByte(COMPRESSION_LEVEL);
+ dataStream.writeByte(this.compressionLevel);
+
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
+
+ ArrayList<byte[]> byteBuffers = new ArrayList<byte[]>();
+ ArrayList<byte[]> byteBuffers = new ArrayList<>();
+ for(int i = 0 ; i < 32 * 32 ; i++) {
+ if(this.bufferUncompressedSize[i] != 0) {
+ chunkCount += 1;
@@ -401,13 +384,13 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ this.buffer[getChunkIndex(pos.x, pos.z)] = b;
+ this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] = uncompressedSize;
+ } catch (IOException e) {
+ LOGGER.error("Chunk write IOException " + e.toString() + " " + this.regionFile);
+ LOGGER.error("Chunk write IOException " + e + " " + this.regionFile);
+ }
+
+ markToSave();
+ }
+
+ public DataOutputStream getChunkDataOutputStream(ChunkPos pos) throws IOException {
+ public DataOutputStream getChunkDataOutputStream(ChunkPos pos) {
+ return new DataOutputStream(new BufferedOutputStream(new LinearRegionFile.ChunkBuffer(pos)));
+ }
+
@@ -439,7 +422,7 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ }
+
+ @Nullable
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException {
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) {
+ if(this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] != 0) {
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
+ byte[] content = new byte[bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]];
@@ -469,7 +452,7 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ try {
+ flush();
+ } catch(IOException e) {
+ throw new IOException("Region flush IOException " + e.toString() + " " + this.regionFile);
+ throw new IOException("Region flush IOException " + e + " " + this.regionFile);
+ }
+ }
+
@@ -477,7 +460,7 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ return (x & 31) + (z & 31) * 32;
+ }
+
+ public boolean recalculateHeader() throws IOException {
+ public boolean recalculateHeader() {
+ return false;
+ }
+
@@ -492,7 +475,7 @@ index 0000000000000000000000000000000000000000..5902bc0cc13d1a77eb547efc7579fd49
+ }
+}
diff --git a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
index a08cde4eefe879adcee7c4118bc38f98c5097ed0..77ce70697f2a634927fd02f2a103c91a7bf09d2a 100644
index a08cde4eefe879adcee7c4118bc38f98c5097ed0..1cfc20b7496f93aff1d6c2387dc5bb8bacab8dc8 100644
--- a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
+++ b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
@@ -811,7 +811,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
@@ -558,31 +541,48 @@ index a08cde4eefe879adcee7c4118bc38f98c5097ed0..77ce70697f2a634927fd02f2a103c91a
}
}
}
@@ -1287,6 +1287,12 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
} catch (final ThreadDeath thr) {
throw thr;
} catch (final Throwable thr) {
+ // Kaiiju start - Linear region format
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
+ failedWrite = thr instanceof IOException;
+ LOGGER.error("Failed to write chunk data for task: " + this.toString(), thr);
+ } else {
+ // Kaiiju end
if (thr instanceof RegionFileStorage.RegionFileSizeException) {
final int maxSize = RegionFile.MAX_CHUNK_SIZE / (1024 * 1024);
LOGGER.error("Chunk at (" + this.chunkX + "," + this.chunkZ + ") in '" + this.world.getWorld().getName() + "' exceeds max size of " + maxSize + "MiB, it has been deleted from disk.");
@@ -1294,6 +1300,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
failedWrite = thr instanceof IOException;
LOGGER.error("Failed to write chunk data for task: " + this.toString(), thr);
}
+ } // Kaiiju
}
diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
index 95cac7edae8ac64811fc6a2f6b97dd4a0fceb0b0..d21077fdcdeb14860ef6f05b7586650051f6d44b 100644
--- a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
+++ b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
@@ -83,9 +83,13 @@ public class ThreadedWorldUpgrader {
}
LOGGER.info("Found " + regionFiles.length + " regionfiles to convert");
LOGGER.info("Starting conversion now for world " + this.worldName);
-
+ // Kaiiju start
+ String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
+ int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
+ LOGGER.info("Using format " + formatName + " (" + linearCompression + ")");
+ // Kaiiju end
final WorldInfo info = new WorldInfo(() -> worldPersistentData,
- new ChunkStorage(regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey);
+ new ChunkStorage(formatName, linearCompression, regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey); // Kaiiju
long expectedChunks = (long)regionFiles.length * (32L * 32L);
final boolean finalFailWrite = failedWrite;
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 75965afd7b4bed23a5ecf618c7f91ff5e7ffd92f..2158c576aa47ef618b7602c2f4e351b7beb023b3 100644
index 75965afd7b4bed23a5ecf618c7f91ff5e7ffd92f..4f4a94f60c60eb8bf4214bfcfe6f963e16b39c98 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -291,7 +291,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
- super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
+ super(world.getLevel().kaiijuConfig.regionFormatName, world.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Kaiiju
// Paper - rewrite chunk system
this.tickingGenerated = new AtomicInteger();
this.playerMap = new PlayerMap();
@@ -336,7 +336,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.lightEngine = new ThreadedLevelLightEngine(chunkProvider, this, this.level.dimensionType().hasSkyLight(), null, null); // Paper - rewrite chunk system
this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor);
this.overworldDataStorage = persistentStateManagerFactory;
- this.poiManager = new PoiManager(path.resolve("poi"), dataFixer, dsync, iregistrycustom, world);
+ this.poiManager = new PoiManager(this.level.kaiijuConfig.regionFormatName, this.level.kaiijuConfig.regionFormatLinearCompressionLevel, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
this.setViewDistance(viewDistance);
// Paper start
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
@@ -950,13 +950,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper start - chunk status cache "api"
@@ -608,42 +608,77 @@ index 75965afd7b4bed23a5ecf618c7f91ff5e7ffd92f..2158c576aa47ef618b7602c2f4e351b7
regionFile.setStatus(chunkPos.x, chunkPos.z, ChunkSerializer.getStatus(compound));
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b396a329e753f42b3878736b6b14bafda02d3744..906d394bbb80b9069645d01a319a9fab24c42288 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -390,9 +390,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
private final EntityRegionFileStorage entityStorage;
private static final class EntityRegionFileStorage extends net.minecraft.world.level.chunk.storage.RegionFileStorage {
-
- public EntityRegionFileStorage(Path directory, boolean dsync) {
- super(directory, dsync);
+ public EntityRegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
+ super(format, linearCompression, directory, dsync); // Kaiiju
}
protected void write(ChunkPos pos, net.minecraft.nbt.CompoundTag nbt) throws IOException {
@@ -583,7 +582,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
// CraftBukkit end
boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper();
- this.entityStorage = new EntityRegionFileStorage(convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
+ this.entityStorage = new EntityRegionFileStorage(this.getLevel().kaiijuConfig.regionFormatName, this.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); // Kaiiju
// this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage, this.entitySliceManager); // Paper // Paper - rewrite chunk system
StructureTemplateManager structuretemplatemanager = minecraftserver.getStructureManager();
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
index 759b125cc1251b9b4f1f443c9f70c482ef5b32f8..aca60733c87f7f95b5719ded24eb8cf697f9d83e 100644
index 759b125cc1251b9b4f1f443c9f70c482ef5b32f8..74bc03e43096c865bba36b15aa248b9dc3481828 100644
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
@@ -61,10 +61,17 @@ public class WorldUpgrader {
@@ -41,7 +41,7 @@ import net.minecraft.world.level.chunk.storage.RegionFile;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.storage.DimensionDataStorage;
import net.minecraft.world.level.storage.LevelStorageSource;
-import org.slf4j.Logger;
+import org.bukkit.Bukkit;import org.bukkit.craftbukkit.CraftWorld;import org.slf4j.Logger;
public class WorldUpgrader {
@@ -61,7 +61,7 @@ public class WorldUpgrader {
private volatile int skipped;
private final Object2FloatMap<ResourceKey<LevelStem>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(Util.identityStrategy())); // CraftBukkit
private volatile Component status = Component.translatable("optimizeWorld.stage.counting");
- public static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
+ public static Pattern REGEX; // Kaiiju
+ public static Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(linear | mca)$"); // Kaiiju
private final DimensionDataStorage overworldDataStorage;
public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, Registry<LevelStem> dimensionOptionsRegistry, boolean eraseCache) {
+ // Kaiiju start
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
+ this.REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.linear$");
+ } else {
+ this.REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
+ }
+ // Kaiiju end
this.dimensions = dimensionOptionsRegistry;
this.levels = (Set) dimensionOptionsRegistry.registryKeySet().stream().collect(Collectors.toUnmodifiableSet()); // CraftBukkit
this.eraseCache = eraseCache;
@@ -235,6 +242,11 @@ public class WorldUpgrader {
@@ -115,8 +115,11 @@ public class WorldUpgrader {
while (iterator1.hasNext()) {
ResourceKey<LevelStem> resourcekey1 = (ResourceKey) iterator1.next(); // CraftBukkit
Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit
-
- builder1.put(resourcekey1, new ChunkStorage(path.resolve("region"), this.dataFixer, true));
+ // Kaiiju start
+ String worldName = this.levelStorage.getLevelId();
+ String formatName = ((CraftWorld) Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
+ builder1.put(resourcekey1, new ChunkStorage(formatName, 6, path.resolve("region"), this.dataFixer, true));
+ // Kaiiju end
}
ImmutableMap<ResourceKey<LevelStem>, ChunkStorage> immutablemap1 = builder1.build(); // CraftBukkit
@@ -235,7 +238,7 @@ public class WorldUpgrader {
File file = this.levelStorage.getDimensionPath((ResourceKey) null).toFile(); // CraftBukkit
File file1 = new File(file, "region");
File[] afile = file1.listFiles((file2, s) -> {
+ // Kaiiju start
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
+ return s.endsWith(".linear");
+ }
+ // Kaiiju end
return s.endsWith(".mca");
- return s.endsWith(".mca");
+ return s.endsWith(".mca") || s.endsWith(".linear"); // Kaiiju
});
@@ -254,7 +266,7 @@ public class WorldUpgrader {
if (afile == null) {
@@ -254,7 +257,7 @@ public class WorldUpgrader {
int l = Integer.parseInt(matcher.group(2)) << 5;
try {
@@ -652,6 +687,40 @@ index 759b125cc1251b9b4f1f443c9f70c482ef5b32f8..aca60733c87f7f95b5719ded24eb8cf6
try {
for (int i1 = 0; i1 < 32; ++i1) {
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
index 8950b220b9a3512cd4667beb7bdec0e82e07edc6..71b38521fd2039bb2ddfdc5dc89341282869ce30 100644
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
@@ -57,8 +57,8 @@ public class PoiManager extends SectionStorage<PoiSection> {
// Paper end - rewrite chunk system
- public PoiManager(Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) {
- super(path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world);
+ public PoiManager(String formatName, int linearCompression, Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) { // Kaiiju
+ super(formatName, linearCompression, path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world); // Kaiiju
this.world = (net.minecraft.server.level.ServerLevel)world; // Paper - rewrite chunk system
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
index 5a425be023d77f0370d102dfb52427147849ac1a..5396d6944cee6c3075fcfd030510254461569120 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
@@ -37,11 +37,12 @@ public class ChunkStorage implements AutoCloseable {
public final RegionFileStorage regionFileCache;
// Paper end - async chunk loading
- public ChunkStorage(Path directory, DataFixer dataFixer, boolean dsync) {
+ public ChunkStorage(String format, int linearCompression, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
this.fixerUpper = dataFixer;
+
// Paper start - async chunk io
// remove IO worker
- this.regionFileCache = new RegionFileStorage(directory, dsync, true); // Paper - nuke IOWorker // Paper
+ this.regionFileCache = new RegionFileStorage(format, linearCompression, directory, dsync, true); // Paper - nuke IOWorker // Paper
// Paper end - async chunk io
}
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 dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788ecafb8e9d 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -714,39 +783,49 @@ index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788e
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) {
return NbtIo.read((java.io.DataInput) out);
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 bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da747cf30c 100644
index bd502ca721de0cab438d995efa00ad0554c0d2fe..ee4005cd62da567d5701d59ddceb212f65a2188d 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
@@ -21,8 +21,9 @@ import net.minecraft.world.level.ChunkPos;
public class RegionFileStorage implements AutoCloseable {
@@ -22,17 +22,25 @@ public class RegionFileStorage implements AutoCloseable {
public static final String ANVIL_EXTENSION = ".mca";
+ public static final String LINEAR_EXTENSION = ".linear"; // Kaiiju
private static final int MAX_CACHE_SIZE = 256;
- public final Long2ObjectLinkedOpenHashMap<RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap();
+ public final Long2ObjectLinkedOpenHashMap<dev.kaiijumc.kaiiju.region.AbstractRegionFile> regionCache = new Long2ObjectLinkedOpenHashMap(); // Kaiiju
private final Path folder;
private final boolean sync;
+ // Kaiiju start - Per world chunk format
+ public final String format;
+ public final int linearCompression;
+ // Kaiiju end
@@ -42,9 +43,17 @@ public class RegionFileStorage implements AutoCloseable {
private final boolean isChunkData; // Paper
- protected RegionFileStorage(Path directory, boolean dsync) { // Paper - protected constructor
+ protected RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Paper - protected constructor
// Paper start - add isChunkData param
- this(directory, dsync, false);
+ this(format, linearCompression, directory, dsync, false);
}
- RegionFileStorage(Path directory, boolean dsync, boolean isChunkData) {
+ RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
+ // Kaiiju start
+ this.format = format;
+ this.linearCompression = linearCompression;
+ // Kaiiju end
this.isChunkData = isChunkData;
// Paper end - add isChunkData param
this.folder = directory;
@@ -42,7 +50,7 @@ public class RegionFileStorage implements AutoCloseable {
// Paper start
public static @Nullable ChunkPos getRegionFileCoordinates(Path file) {
String fileName = file.getFileName().toString();
+ // Kaiiju start
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
+ if (!fileName.startsWith("r.") || !fileName.endsWith(".linear")) {
+ return null;
+ }
+ } else {
+ // Kaiiju end
if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
- if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
+ if (!fileName.startsWith("r.") || !fileName.endsWith(".mca") || !fileName.endsWith(".linear")) { // Kaiiju
return null;
}
+ } // Kaiiju
String[] split = fileName.split("\\.");
@@ -62,49 +71,57 @@ public class RegionFileStorage implements AutoCloseable {
@@ -62,49 +70,66 @@ public class RegionFileStorage implements AutoCloseable {
}
}
@@ -792,18 +871,28 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
Path path = this.folder;
int j = chunkcoordintpair.getRegionX();
- Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change
+ // Kaiiju start
- if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit
- RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header
+ // Kaiiju start - Polyglot
+ //Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change
+ Path path1;
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear");
+ if (existingOnly) {
+ Path anvil = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
+ Path linear = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear");
+ if (java.nio.file.Files.exists(anvil)) path1 = anvil;
+ else if (java.nio.file.Files.exists(linear)) path1 = linear;
+ else return null;
+ } else {
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
+ String extension = switch (this.format) {
+ case "LINEAR" -> "linear";
+ default -> "mca";
+ };
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + "." + extension);
+ }
+ //if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit
+ // Kaiiju end
if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit
- RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile1 = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header // Kaiiju
+
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile1 = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(this.linearCompression, path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header // Kaiiju
this.regionCache.putAndMoveToFirst(i, regionfile1);
// Paper start
@@ -814,7 +903,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
}
// Paper end
return regionfile1;
@@ -132,7 +149,7 @@ public class RegionFileStorage implements AutoCloseable {
@@ -132,7 +157,7 @@ public class RegionFileStorage implements AutoCloseable {
}
@@ -823,7 +912,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
synchronized (regionfile) {
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
@@ -179,14 +196,14 @@ public class RegionFileStorage implements AutoCloseable {
@@ -179,14 +204,14 @@ public class RegionFileStorage implements AutoCloseable {
@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
@@ -840,7 +929,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
// We add the regionfile parameter to avoid the potential deadlock (on fileLock) if we went back to obtain a regionfile
// if we decide to re-read
// Paper end
@@ -196,7 +213,7 @@ public class RegionFileStorage implements AutoCloseable {
@@ -196,7 +221,7 @@ public class RegionFileStorage implements AutoCloseable {
// Paper start
if (regionfile.isOversized(pos.x, pos.z)) {
@@ -849,7 +938,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
return readOversizedChunk(regionfile, pos);
}
// Paper end
@@ -210,12 +227,12 @@ public class RegionFileStorage implements AutoCloseable {
@@ -210,12 +235,12 @@ public class RegionFileStorage implements AutoCloseable {
if (this.isChunkData) {
ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(nbttagcompound);
if (!chunkPos.equals(pos)) {
@@ -865,7 +954,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
return null;
}
}
@@ -249,13 +266,13 @@ public class RegionFileStorage implements AutoCloseable {
@@ -249,13 +274,13 @@ public class RegionFileStorage implements AutoCloseable {
return nbttagcompound;
} finally { // Paper start
@@ -881,7 +970,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
if (regionfile == null) {
return;
}
@@ -285,7 +302,7 @@ public class RegionFileStorage implements AutoCloseable {
@@ -285,7 +310,7 @@ public class RegionFileStorage implements AutoCloseable {
}
protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
@@ -890,7 +979,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
if (nbt == null && regionfile == null) {
return;
}
@@ -335,7 +352,7 @@ public class RegionFileStorage implements AutoCloseable {
@@ -335,7 +360,7 @@ public class RegionFileStorage implements AutoCloseable {
}
// Paper end
} finally { // Paper start
@@ -899,7 +988,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
} // Paper end
}
@@ -344,7 +361,7 @@ public class RegionFileStorage implements AutoCloseable {
@@ -344,7 +369,7 @@ public class RegionFileStorage implements AutoCloseable {
ObjectIterator objectiterator = this.regionCache.values().iterator();
while (objectiterator.hasNext()) {
@@ -908,7 +997,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
try {
regionfile.close();
@@ -360,7 +377,7 @@ public class RegionFileStorage implements AutoCloseable {
@@ -360,7 +385,7 @@ public class RegionFileStorage implements AutoCloseable {
ObjectIterator objectiterator = this.regionCache.values().iterator();
while (objectiterator.hasNext()) {
@@ -917,6 +1006,21 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
regionfile.flush();
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
index d783072bc964e45c308197e6f79874eb4a09f871..261613054a4ba0e78ad1aec819d743eaaae01cf2 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
@@ -47,8 +47,8 @@ public class SectionStorage<R> extends RegionFileStorage implements AutoCloseabl
public final RegistryAccess registryAccess; // Paper - rewrite chunk system
protected final LevelHeightAccessor levelHeightAccessor;
- public SectionStorage(Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) {
- super(path, dsync); // Paper - remove mojang I/O thread
+ public SectionStorage(String format, int linearCompression, Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) { // Kaiiju
+ super(format, linearCompression, path, dsync); // Paper - remove mojang I/O thread // Kaiiju
this.codec = codecFactory;
this.factory = factory;
this.fixerUpper = dataFixer;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 9b5323edd99848b73ea0e34230e7bec8dc23be8c..619c7713d573e8f438ea23a3fcb185a98abf5100 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java

View File

@@ -5,16 +5,15 @@ Subject: [PATCH] Kaiiju Lobotomize Configuration
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19..ac4440f8d2bd30e3e074ef797d5138b64996fcbb 100644
index b194f4dbebcbbf5bb4e026a0169e2d24806b46ec..907fdfb368c87bfe7b4374bb0b5f49d5ff095339 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -122,4 +122,7 @@ public class KaiijuWorldConfig {
final Map<String, Object> value = getMap("world-settings." + worldName + "." + path, null);
return value.isEmpty() ? fallback : value;
@@ -143,4 +143,7 @@ public class KaiijuWorldConfig {
regionFormatLinearCompressionLevel = 1;
}
}
-}
\ No newline at end of file
+
+ private void lobotomizeSettings() {
+ }
+}
}
\ No newline at end of file

View File

@@ -7,11 +7,11 @@ Inspired by "Lobotomized animals" by @KioProject123
Checks might be a nuisance to performance.
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index ac4440f8d2bd30e3e074ef797d5138b64996fcbb..d28f05943ef25aad1d5a0d4d3f72b991a3caaa5f 100644
index 907fdfb368c87bfe7b4374bb0b5f49d5ff095339..b99b438b92587f23c77c5321d5d23e76dc5450de 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -123,6 +123,17 @@ public class KaiijuWorldConfig {
return value.isEmpty() ? fallback : value;
@@ -144,6 +144,17 @@ public class KaiijuWorldConfig {
}
}
+ public boolean lobotomizeAnimalEnabled = false;
@@ -28,6 +28,7 @@ index ac4440f8d2bd30e3e074ef797d5138b64996fcbb..d28f05943ef25aad1d5a0d4d3f72b991
+ lobotomizeAnimalFloat = getBoolean("lobotomize.animal.float", lobotomizeAnimalFloat);
}
}
\ No newline at end of file
diff --git a/src/main/java/dev/kaiijumc/kaiiju/entity/Lobotomized.java b/src/main/java/dev/kaiijumc/kaiiju/entity/Lobotomized.java
new file mode 100644
index 0000000000000000000000000000000000000000..805df3e27cfbbdf3525c96942afca12d50abc350

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Kaiiju Lobotomize Villager
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index d28f05943ef25aad1d5a0d4d3f72b991a3caaa5f..af0db4449ae7b3b12cc3351f94878ef68edb21bc 100644
index b99b438b92587f23c77c5321d5d23e76dc5450de..104f19cced8fb3b692e3a4772360d9eba3bdd6f2 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -128,6 +128,13 @@ public class KaiijuWorldConfig {
@@ -149,6 +149,13 @@ public class KaiijuWorldConfig {
public boolean lobotomizeAnimalCheckCanJump = true;
public boolean lobotomizeAnimalLookAtPlayer = false;
public boolean lobotomizeAnimalFloat = true;
@@ -22,7 +22,7 @@ index d28f05943ef25aad1d5a0d4d3f72b991a3caaa5f..af0db4449ae7b3b12cc3351f94878ef6
private void lobotomizeSettings() {
lobotomizeAnimalEnabled = getBoolean("lobotomize.animal.enabled", lobotomizeAnimalEnabled);
@@ -135,5 +142,12 @@ public class KaiijuWorldConfig {
@@ -156,5 +163,12 @@ public class KaiijuWorldConfig {
lobotomizeAnimalCheckCanJump = getBoolean("lobotomize.animal.check-can-jump", lobotomizeAnimalCheckCanJump);
lobotomizeAnimalLookAtPlayer = getBoolean("lobotomize.animal.look-at-player", lobotomizeAnimalLookAtPlayer);
lobotomizeAnimalFloat = getBoolean("lobotomize.animal.float", lobotomizeAnimalFloat);
@@ -35,6 +35,7 @@ index d28f05943ef25aad1d5a0d4d3f72b991a3caaa5f..af0db4449ae7b3b12cc3351f94878ef6
+ lobotomizeVillagerCheckBedNearby = getBoolean("lobotomize.villager.check-bed-nearby", lobotomizeVillagerCheckBedNearby);
}
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index aed1d9ccffe471b6c2a1d52d2d3d097f6431318b..f1a66bda9949eff5f8e420d28d23f47aec3d4587 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java

View File

@@ -5,12 +5,12 @@ Subject: [PATCH] Kaiiju Network Configuration
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 2ae67b36a08688c3041635c2db04b05e295c4eea..1fb42e9ead32ddd964b22cb1778ccf1bd8e43dbc 100644
index 7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027..2791fe6cc78cc13d969a903134c08e992a6ecdca 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -211,4 +211,7 @@ public class KaiijuConfig {
regionFormatLinearCompressionLevel = 1;
@@ -192,4 +192,7 @@ public class KaiijuConfig {
}
return builder.build();
}
+
+ private static void networkSettings() {

View File

@@ -5,11 +5,11 @@ Subject: [PATCH] Purpur Network Send Null Entity Packets
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 1fb42e9ead32ddd964b22cb1778ccf1bd8e43dbc..ea963a1d75c11e0e01b04adaea261a63b7a9a430 100644
index 2791fe6cc78cc13d969a903134c08e992a6ecdca..276c0e2936dfd3ca752deb65c80565c477f65e7f 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -212,6 +212,8 @@ public class KaiijuConfig {
}
@@ -193,6 +193,8 @@ public class KaiijuConfig {
return builder.build();
}
+ public static boolean sendNullEntityPackets = true;

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Kaiiju Lithium Configuration
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index ea963a1d75c11e0e01b04adaea261a63b7a9a430..0f214dc5f4c585911953c4aaaa54cf43f340e4eb 100644
index 276c0e2936dfd3ca752deb65c80565c477f65e7f..98c11996a4f052e4e8f1b2782e214817a7999677 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -216,4 +216,9 @@ public class KaiijuConfig {
@@ -197,4 +197,9 @@ public class KaiijuConfig {
private static void networkSettings() {
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
}

View File

@@ -7,10 +7,10 @@ Author: JellySquid
Licence: LGPL-3.0
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 0f214dc5f4c585911953c4aaaa54cf43f340e4eb..9020f9d2ce1a0612f21fb0ba25c07c752475bb5a 100644
index 98c11996a4f052e4e8f1b2782e214817a7999677..259f7bdca1b9f59dd148492f8f8fe7dc959e55d9 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -218,7 +218,9 @@ public class KaiijuConfig {
@@ -199,7 +199,9 @@ public class KaiijuConfig {
}
public static boolean lithiumEnable = true;

View File

@@ -7,10 +7,10 @@ Author: JellySquid
Licence: LGPL-3.0
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 9020f9d2ce1a0612f21fb0ba25c07c752475bb5a..dca9c796317b988ae5963dd2d452c2b8162a2249 100644
index 259f7bdca1b9f59dd148492f8f8fe7dc959e55d9..a4f9f31941ddd119dca74f3e23bf8507ee4b7369 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -219,8 +219,10 @@ public class KaiijuConfig {
@@ -200,8 +200,10 @@ public class KaiijuConfig {
public static boolean lithiumEnable = true;
public static boolean lithiumMathFastUtil = true;