Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 43 additions & 14 deletions SLIME_FORMAT
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
-------------------------------------

“Slime” file format
“Slime” file format (Version 13)
2 bytes - magic = 0xB10B
1 byte (ubyte) - version, current = 0x0C
1 byte (ubyte) - version, current = 0x0D
4 bytes (int) - world version
1 byte (ubyte) - additional world flags (bitmask - see options below)
4 bytes (int) - compressed chunks size
4 bytes (int) - uncompressed chunks size
<array of chunks> (size determined from bitmask)
Expand All @@ -13,35 +14,62 @@
4 bytes (int) - uncompressed “extra” size
[depends] - extra compound tag compressed using zstd (used for PDC, and/or custom data)

-------------------------------------
Additional world flag index
POI_CHUNKS - Enum ordinal 0 - Bitmask value 1
FLUID_TICKS - Enum ordinal 1 - Bitmask value 2
BLOCK_TICKS - Enum ordinal 2 - Bitmask value 4
-------------------------------------

Custom chunk format
4 byte (int) - chunk x
4 byte (int) - chunk z
4 bytes (int) section count
[for each section]
1 byte (boolean) - has sky light
1 byte (ubyte) - section flags (Bitmask value 1 = has block light, 2 = has sky light)
[if has sky light]
2048 bytes - sky light
1 byte (boolean) - has block light
[if has block light]
2048 bytes - block light
[if has block light]
2048 bytes - block light
4 bytes (int) - block states byte size
<block states component>
<block states nbt compound>
same format as mc
4 bytes (int) - biomes byte size
<biomes component>
<biomes nbt compound>
same format as mc
4 bytes (int) - heightmaps size
<array of heightmap nbt compounds>
<nbt compound>
same format as mc, uncompressed
[if poi chunks flag is enabled]
4 bytes (int) - poi chunk size
<nbt compound>
"Sections" tag of the mc poi chunk compound
uncompressed
[if block ticks flag is enabled]
4 bytes (int) - fluid ticks size
<nbt compound>
Same format as mc
inside an nbt list named "block_ticks"
uncompressed
[if fluid ticks flag is enabled]
4 bytes (int) - heightmaps size
<nbt compound>
Same format as mc
inside an nbt list named "fluid_ticks"
uncompressed
[for every flag set that does not exist yet, for backward compatibility of new future flags]
4 bytes (int) - size
<byte array with unsupported yet undocumented data>

4 bytes (int) - tile entities size
<array of tile entity nbt compounds>
<nbt compound>
Same format as mc
inside an nbt list named “tileEntities”, in a global compound
inside an nbt list named “tileEntities”
uncompressed
4 bytes (int) entities size
<array of entity nbt compounds>
Same format as mc EXCEPT optional “CustomId”
inside an nbt list named “entities”, in a global compound
<nbt compound>
Same format as mc
inside an nbt list named “entities”
uncompressed
[depends] - compound tag uncompressed (used for PDC, and/or custom data

Expand All @@ -60,3 +88,4 @@ Version history:
- v10: Use minecraft version id, remove legacy version artifacts
- v11: Move entities and tile entities into the chunk structure
- v12: Add support for chunk-based PDC
- v13: Add support for additional world data
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public class SlimeFormat {
public static final byte[] SLIME_HEADER = new byte[] { -79, 11 };

/** Latest version of the SRF that SWM supports **/
public static final byte SLIME_VERSION = 12;
public static final byte SLIME_VERSION = 13;
}
40 changes: 40 additions & 0 deletions api/src/main/java/com/infernalsuite/asp/api/world/SlimeChunk.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.infernalsuite.asp.api.world;

import com.infernalsuite.asp.api.world.properties.SlimeProperties;
import net.kyori.adventure.nbt.BinaryTag;
import net.kyori.adventure.nbt.CompoundBinaryTag;
import net.kyori.adventure.nbt.ListBinaryTag;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -38,6 +40,7 @@ public interface SlimeChunk {
*
* @return A {@link CompoundBinaryTag} containing all the height maps of the chunk.
*/
@Nullable
CompoundBinaryTag getHeightMaps();

/**
Expand Down Expand Up @@ -73,4 +76,41 @@ public interface SlimeChunk {
*/
@Nullable
CompoundBinaryTag getUpgradeData();

/**
* Returns all block ticks of the chunk. This data is only saved when {@link SlimeProperties#SAVE_BLOCK_TICKS} is true.
* <p>
* Even if {@link SlimeProperties#SAVE_BLOCK_TICKS} is false, this might still return
* a {@link ListBinaryTag} containing the block ticks, if the data was present when the world
* was read or when the chunk is currently loaded.
*
* @return A {@link ListBinaryTag} containing all the block ticks of the chunk, if present.
* @see SlimeProperties#SAVE_FLUID_TICKS
*/
@Nullable
ListBinaryTag getBlockTicks();

/**
* Returns all fluid ticks of the chunk. This data is only saved when {@link SlimeProperties#SAVE_FLUID_TICKS} is true.
* <p>
* Even if {@link SlimeProperties#SAVE_FLUID_TICKS} is false, this might still return a {@link ListBinaryTag}
* containing the fluid ticks, if the data was present when the world was read or when the chunk is currently loaded.
*
* @return A {@link ListBinaryTag} containing all the fluid ticks of the chunk, if present.
* @see SlimeProperties#SAVE_FLUID_TICKS
*/
@Nullable
ListBinaryTag getFluidTicks();

/**
* Returns the poi sections of the chunk. This data is only saved when {@link SlimeProperties#SAVE_POI} is true.
* <p>
* Even if {@link SlimeProperties#SAVE_POI} is false, this might still return a {@link CompoundBinaryTag}
* containing the poi sections, if the data was present when the world was read or when the chunk is currently loaded.
*
* @return A {@link CompoundBinaryTag} containing the poi chunks of the chunk, if present.
* @see SlimeProperties#SAVE_POI
*/
@Nullable
CompoundBinaryTag getPoiChunkSections();
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,39 @@ public class SlimeProperties {
value.equalsIgnoreCase("aggressive") || value.equalsIgnoreCase("never")
);



@ApiStatus.Experimental
public static final SlimePropertyInt CHUNK_SECTION_MIN = SlimePropertyInt.create("chunkSectionMin", -4);
@ApiStatus.Experimental
public static final SlimePropertyInt CHUNK_SECTION_MAX = SlimePropertyInt.create("chunkSectionMax", 19);

/**
* The sea level to use for the slime world. This affects mob spawning for water specific mobs like squids or turtles.
* To achieve the default vanilla behaviour, change this value to 63 instead of the default of -63.
*/
@ApiStatus.Experimental
public static final SlimePropertyInt SEA_LEVEL = SlimePropertyInt.create("seaLevel", -63);

/**
* Whether to save the POI data in the world or not. Worlds that already have POI data will still load the data
* even if this is set to false. However, the POI data will no longer be saved when the world is saved.
* <p>
* POI data is e.g. used for villager jobs, villager beds, bees, lightning rods. This data is not saved in slime by default.
*/
public static final SlimePropertyBoolean SAVE_POI = SlimePropertyBoolean.create("savePOI", false);

/**
* Whether to save the block ticks in the world or not. Worlds that already have block tick data will still load the data
* even if this is set to false. However, the block tick data will no longer be saved when the world is saved.
* <p>
* Block ticks are used for scheduling e.g. redstone updates. If this data is not saved, redstone will pause when chunks or worlds get re-loaded.
*/
public static final SlimePropertyBoolean SAVE_BLOCK_TICKS = SlimePropertyBoolean.create("saveBlockTicks", false);

/**
* Whether to save the fluid ticks in the world or not. Worlds that already have fluid tick data will still load the data
* even if this is set to false. However, the fluid tick data will no longer be saved when the world is saved.
* <p>
* Fluid ticks are used for scheduling liquid flow updates. If this data is not saved, fluids will freeze when chunks or worlds get re-loaded.
*/
public static final SlimePropertyBoolean SAVE_FLUID_TICKS = SlimePropertyBoolean.create("saveFluidTicks", false);
}
19 changes: 9 additions & 10 deletions aspaper-api/build.gradle.kts.patch
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
--- a/paper-api/build.gradle.kts
+++ b/paper-api/build.gradle.kts
@@ -39,7 +_,7 @@
@@ -40,6 +_,7 @@
}

dependencies {
-
+ api(project(":api")) //ASP
// api dependencies are listed transitively to API consumers
api("com.google.guava:guava:33.3.1-jre")
api("com.google.code.gson:gson:2.11.0")
@@ -93,7 +_,7 @@
@@ -90,7 +_,7 @@
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

-val generatedApiPath: java.nio.file.Path = layout.projectDirectory.dir("src/generated/java").asFile.toPath()
+val generatedApiPath: java.nio.file.Path = rootProject.layout.projectDirectory.dir("paper-api/src/generated/java").asFile.toPath()
-val generatedDir: java.nio.file.Path = layout.projectDirectory.dir("src/generated/java").asFile.toPath()
+val generatedDir: java.nio.file.Path = rootProject.layout.projectDirectory.dir("paper-api/src/generated/java").asFile.toPath()
idea {
module {
generatedSourceDirs.add(generatedApiPath.toFile())
@@ -103,6 +_,18 @@
generatedSourceDirs.add(generatedDir.toFile())
@@ -100,6 +_,18 @@
main {
java {
srcDir(generatedApiPath)
srcDir(generatedDir)
+ srcDir(file("../paper-api/src/main/java"))
+ }
+ resources {
Expand All @@ -37,7 +36,7 @@
}
}
}
@@ -169,7 +_,7 @@
@@ -166,7 +_,7 @@

tasks.withType<Javadoc> {
val options = options as StandardJavadocDocletOptions
Expand All @@ -46,7 +45,7 @@
options.use()
options.isDocFilesSubDirs = true
options.links(
@@ -202,11 +_,11 @@
@@ -199,11 +_,11 @@
}

// workaround for https://github.com/gradle/gradle/issues/4046
Expand Down
27 changes: 17 additions & 10 deletions aspaper-server/build.gradle.kts.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
--- a/paper-server/build.gradle.kts
+++ b/paper-server/build.gradle.kts
@@ -21,6 +_,17 @@
// macheOldPath = file("F:\\Projects\\PaperTooling\\mache\\versions\\1.21.4\\src\\main\\java")
// gitFilePatches = true
@@ -26,6 +_,17 @@
minecraftVersion = providers.gradleProperty("mcVersion")
gitFilePatches = false

+ val aspaper = forks.register("aspaper") {
+ upstream.patchDir("paperServer") {
Expand All @@ -16,9 +16,9 @@
+ activeFork = aspaper
+
spigot {
buildDataRef = "3edaf46ec1eed4115ce1b18d2846cded42577e42"
packageVersion = "v1_21_R3" // also needs to be updated in MappingEnvironment
@@ -101,7 +_,20 @@
enabled = true
buildDataRef = "436eac9815c211be1a2a6ca0702615f995e81c44"
@@ -107,7 +_,19 @@
}
}

Expand All @@ -33,25 +33,23 @@
+ resources { srcDir("../paper-server/src/test/resources") }
+ }
+}
+
+val log4jPlugins = sourceSets.create("log4jPlugins") {
+ java { srcDir("../paper-server/src/log4jPlugins/java") }
+}
configurations.named(log4jPlugins.compileClasspathConfigurationName) {
extendsFrom(configurations.compileClasspath.get())
}
@@ -119,7 +_,9 @@
@@ -129,7 +_,8 @@
}

dependencies {
- implementation(project(":paper-api"))
+ implementation(project(":aspaper-api")) //ASP
+ implementation(project(":core")) //ASP
+ implementation("commons-io:commons-io:2.11.0")
implementation("ca.spottedleaf:concurrentutil:0.0.3")
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
@@ -189,14 +_,14 @@
@@ -205,14 +_,14 @@
val gitBranch = git.exec(providers, "rev-parse", "--abbrev-ref", "HEAD").get().trim()
attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main",
Expand All @@ -71,3 +69,12 @@
"Build-Number" to (build ?: ""),
"Build-Time" to buildTime.toString(),
"Git-Branch" to gitBranch,
@@ -271,7 +_,7 @@
jvmArgumentProviders.add(provider)
}

-val generatedDir: java.nio.file.Path = layout.projectDirectory.dir("src/generated/java").asFile.toPath()
+val generatedDir: java.nio.file.Path = rootProject.layout.projectDirectory.dir("paper-server/src/generated/java").asFile.toPath()
idea {
module {
generatedSourceDirs.add(generatedDir.toFile())
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Disable dragon battle


diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index c5ddf6c0f0ff795da2f7aec8915a081b334423ec..a373f5b8e03f4179a4d9f63d79abc19a38f952b6 100644
index 53ec0565a76663de74bb228c23c3d74a640a20f9..2c85ace929aeb9078fe868bcc56a2be08ac2f7ba 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -689,7 +689,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -684,7 +684,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
);
this.structureManager = new StructureManager(this, this.serverLevelData.worldGenOptions(), this.structureCheck); // CraftBukkit
if (this.dimension() == Level.END && this.dimensionTypeRegistration().is(BuiltinDimensionTypes.END) || env == org.bukkit.World.Environment.THE_END) { // CraftBukkit - Allow to create EnderDragonBattle in default and custom END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] World overrides


diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 1509c96ae9247d1d5ddd0fc50210f88da10bf3de..bbc4be3c3811ee19bd791cb6626474038d35a298 100644
index 3349baa2ab971db435b88083688bd0f99474607e..610e58bede7e1482fc861ab6559f4f3a6e7e3633 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -516,18 +516,33 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Subject: [PATCH] Avoid IO call for UUID


diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 8429a97047f4321df96fd11559867bce74d0a49c..60608cea4e564c1ce47f8a4de2c1a48986bbdecb 100644
index 2c85ace929aeb9078fe868bcc56a2be08ac2f7ba..939605ce630ab66b7236962dec3ae61ed23dc222 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -617,7 +617,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -612,7 +612,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor
this.pvpMode = server.isPvpAllowed();
this.levelStorageAccess = levelStorageAccess;
- this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getUUID(levelStorageAccess.levelDirectory.path().toFile());
+ this.uuid = bootstrap == null ? org.bukkit.craftbukkit.util.WorldUUID.getUUID(levelStorageAccess.levelDirectory.path().toFile()) : UUID.randomUUID(); //ASP - avoid IO calls
- this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile());
+ this.uuid = bootstrap == null ? org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile()) : java.util.UUID.randomUUID(); //ASP - avoid IO calls
// CraftBukkit end
this.tickTime = tickTime;
this.server = server;
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ Subject: [PATCH] Prevent config disk io on world load


diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 60608cea4e564c1ce47f8a4de2c1a48986bbdecb..1b5d65136421b63353b1c6cd8ae5d413ec070b92 100644
index 939605ce630ab66b7236962dec3ae61ed23dc222..51cfeb87385b7e40922049a197a417a3892c2fce 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -614,7 +614,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -609,7 +609,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
) {
//ASP end
// CraftBukkit start
- super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor
+ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> bootstrap != null ? com.infernalsuite.asp.config.SlimePaperWorldConfig.initializeOrGet() : server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor //ASP - Optimize world config
this.pvpMode = server.isPvpAllowed();
this.levelStorageAccess = levelStorageAccess;
this.uuid = bootstrap == null ? org.bukkit.craftbukkit.util.WorldUUID.getUUID(levelStorageAccess.levelDirectory.path().toFile()) : UUID.randomUUID(); //ASP - avoid IO calls
this.uuid = bootstrap == null ? org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile()) : java.util.UUID.randomUUID(); //ASP - avoid IO calls
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 1dbe7c7c1051c3972105534a07ce50d4cf98fc85..e1d3c292b9efccb032245f4f1618f2650f0bc619 100644
index e4b9a564aad3d9b673808caa18265b06592ceab8..8bb30eba86b74f155ef9580dc6c01d761e23dd5a 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -851,7 +851,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -838,7 +838,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
this.maxSectionY = this.maxY >> 4;
this.sectionsCount = this.maxSectionY - this.minSectionY + 1;
// Paper end - getblock optimisations - cache world height/sections
- this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot
+ this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName(), !(this instanceof com.infernalsuite.asp.level.SlimeLevelInstance)); // Spigot //ASP - Improve Slime IO
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
this.generator = gen;
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
this.generator = generator;
this.world = new CraftWorld((ServerLevel) this, generator, biomeProvider, environment);
Loading