From e3f4640b95a0dd5ebfd1202820ac1586cadda9a7 Mon Sep 17 00:00:00 2001 From: GliczDev <67753196+GliczDev@users.noreply.github.com> Date: Sat, 29 Mar 2025 14:07:02 +0100 Subject: [PATCH] Document SRF v12 --- format/SRF_v12.md | 59 +++++++++++++++++++ .../net/roxymc/slime/loader/SlimeLoader.java | 2 +- .../slime/serializer/SlimeSerializer_v12.java | 2 +- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 format/SRF_v12.md diff --git a/format/SRF_v12.md b/format/SRF_v12.md new file mode 100644 index 0000000..eb0b5c0 --- /dev/null +++ b/format/SRF_v12.md @@ -0,0 +1,59 @@ +# SRF (Slime Region Format) v12 Specification + +This document describes the structure of the SRF v12 file format for storing Minecraft world regions. + +## 1. World Format + +An SRF file begins with the following structure: + +| Data Type | Size (Bytes) | Description | +|-----------------------------|--------------|--------------------------------------------------------------------------------------------------| +| `header` | 2 | **Header:** `0xB10B` (Identifies SRF file) | +| `version` | 1 (ubyte) | **Format Version:** `0x0C` (SRF v12) | +| `worldVersion` | 4 (int) | **Minecraft World Version:** Integer representing the Minecraft version the region was saved in. | +| `compressedChunksSize` | 4 (int) | **Compressed Chunks Size:** Size (in bytes) of the compressed chunk data (see below). | +| `uncompressedChunksSize` | 4 (int) | **Uncompressed Chunks Size:** Size (in bytes) of the uncompressed chunk data. | +| `chunks` | - | **Chunks Data:** An array of chunk structures, compressed using Zstd. | +| `compressedExtraDataSize` | 4 (int) | **Compressed Extra Data Size:** Size (in bytes) of the compressed extra data. | +| `uncompressedExtraDataSize` | 4 (int) | **Uncompressed Extra Data Size:** Size (in bytes) of the uncompressed extra data. | +| `extraData` | - | **Extra Data:** A Compound NBT tag containing any additional world data, compressed using Zstd. | + +## 2. Chunk Format + +The `chunks` section from the World Format is composed of individual chunk structures. Each chunk has the following +format: + +| Data Type | Size (Bytes) | Description | +|---------------------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `chunkX` | 4 (int) | **Chunk X Coordinate:** The X coordinate of the chunk. | +| `chunkZ` | 4 (int) | **Chunk Z Coordinate:** The Z coordinate of the chunk. | +| `sectionCount` | 4 (int) | **Section Count:** The number of sections in this chunk. | +| `sections` | - | **Sections Data:** An array of section structures (see below). | +| `heightmapsSize` | 4 (int) | **Heightmaps Size:** Size (in bytes) of the heightmaps NBT data. | +| `heightmaps` | - | **Heightmaps:** A Compound NBT tag containing the heightmap data in the standard Minecraft format. | +| `blockEntitiesSize` | 4 (int) | **Block Entities Size:** Size (in bytes) of the block entities NBT data. | +| `blockEntities` | - | **Block Entities:** A Compound NBT tag containing a list of block entities: `{ "tileEntities": [ ... ] }`. The `tileEntities` tag is an array of Compound NBT tags, each representing a block entity in the standard Minecraft format. | +| `entitiesSize` | 4 (int) | **Entities Size:** Size (in bytes) of the entities NBT data. | +| `entities` | - | **Entities:** A Compound NBT tag containing a list of entities:` { "entities": [ ... ] }`. The `entities` tag is an array of Compound NBT tags, each representing an entity in the standard Minecraft format. | +| `extraDataSize` | 4 (int) | **Extra Data Size:** Size (in bytes) of the extra data NBT data. | +| `extraData` | - | **Extra Data:** A Compound NBT tag containing any additional chunk data. | + +## 3. Section Format + +The `sections` section from the Chunk Format is composed of individual section structures. Each section has the following format: + +| Data Type | Size (Bytes) | Description | +|-------------------|--------------|--------------------------------------------------------------------------------------------------------| +| `hasSkyLight` | 1 (boolean) | **Has Sky Light:** `true` if sky light data is present, `false` otherwise. | +| `skyLight` | 2048 | **Sky Light Data:** (Optional, present if `hasSkyLight` is `true`) 2048 bytes of sky light data. | +| `hasBlockLight` | 1 (boolean) | **Has Block Light:** `true` if block light data is present, `false` otherwise. | +| `blockLight` | 2048 | **Block Light Data:** (Optional, present if `hasBlockLight` is `true`) 2048 bytes of block light data. | +| `blockStatesSize` | 4 (int) | **Block States Size:** Size (in bytes) of the block states NBT data. | +| `blockStates` | - | **Block States:** A Compound NBT tag containing the block states data. | +| `biomesSize` | 4 (int) | **Biomes Size:** Size (in bytes) of the biomes NBT data. | +| `biomes` | - | **Biomes:** A Compound NBT tag containing the biome data. | + +## Notes: + +* "Minecraft format" for NBT tags refers to the standard NBT structure used by Minecraft for storing world data. +* Boolean 1 stands for TRUE, boolean 0 stands for FALSE diff --git a/slime-loader/src/main/java/net/roxymc/slime/loader/SlimeLoader.java b/slime-loader/src/main/java/net/roxymc/slime/loader/SlimeLoader.java index 9dd56eb..b4bd737 100644 --- a/slime-loader/src/main/java/net/roxymc/slime/loader/SlimeLoader.java +++ b/slime-loader/src/main/java/net/roxymc/slime/loader/SlimeLoader.java @@ -15,7 +15,7 @@ import static net.roxymc.slime.util.ObjectUtils.nonNull; public class SlimeLoader { - public static final byte[] SLIME_HEADER = new byte[]{-79, 11}; + public static final byte[] SLIME_HEADER = new byte[]{-79, 11}; // 0xB10B private final Deserializers deserializers; diff --git a/slime-loader/src/main/java/net/roxymc/slime/serializer/SlimeSerializer_v12.java b/slime-loader/src/main/java/net/roxymc/slime/serializer/SlimeSerializer_v12.java index 3207cbc..c51c5ce 100644 --- a/slime-loader/src/main/java/net/roxymc/slime/serializer/SlimeSerializer_v12.java +++ b/slime-loader/src/main/java/net/roxymc/slime/serializer/SlimeSerializer_v12.java @@ -17,7 +17,7 @@ import java.io.IOException; public class SlimeSerializer_v12 extends SlimeSerializer { - public static final byte VERSION = 12; + public static final byte VERSION = 12; // 0x0C protected static final String TILE_ENTITIES = "tileEntities"; protected static final String ENTITIES = "entities";