Skip to content

Commit e3f4640

Browse files
committed
Document SRF v12
1 parent 1ec54a8 commit e3f4640

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

format/SRF_v12.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SRF (Slime Region Format) v12 Specification
2+
3+
This document describes the structure of the SRF v12 file format for storing Minecraft world regions.
4+
5+
## 1. World Format
6+
7+
An SRF file begins with the following structure:
8+
9+
| Data Type | Size (Bytes) | Description |
10+
|-----------------------------|--------------|--------------------------------------------------------------------------------------------------|
11+
| `header` | 2 | **Header:** `0xB10B` (Identifies SRF file) |
12+
| `version` | 1 (ubyte) | **Format Version:** `0x0C` (SRF v12) |
13+
| `worldVersion` | 4 (int) | **Minecraft World Version:** Integer representing the Minecraft version the region was saved in. |
14+
| `compressedChunksSize` | 4 (int) | **Compressed Chunks Size:** Size (in bytes) of the compressed chunk data (see below). |
15+
| `uncompressedChunksSize` | 4 (int) | **Uncompressed Chunks Size:** Size (in bytes) of the uncompressed chunk data. |
16+
| `chunks` | - | **Chunks Data:** An array of chunk structures, compressed using Zstd. |
17+
| `compressedExtraDataSize` | 4 (int) | **Compressed Extra Data Size:** Size (in bytes) of the compressed extra data. |
18+
| `uncompressedExtraDataSize` | 4 (int) | **Uncompressed Extra Data Size:** Size (in bytes) of the uncompressed extra data. |
19+
| `extraData` | - | **Extra Data:** A Compound NBT tag containing any additional world data, compressed using Zstd. |
20+
21+
## 2. Chunk Format
22+
23+
The `chunks` section from the World Format is composed of individual chunk structures. Each chunk has the following
24+
format:
25+
26+
| Data Type | Size (Bytes) | Description |
27+
|---------------------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
28+
| `chunkX` | 4 (int) | **Chunk X Coordinate:** The X coordinate of the chunk. |
29+
| `chunkZ` | 4 (int) | **Chunk Z Coordinate:** The Z coordinate of the chunk. |
30+
| `sectionCount` | 4 (int) | **Section Count:** The number of sections in this chunk. |
31+
| `sections` | - | **Sections Data:** An array of section structures (see below). |
32+
| `heightmapsSize` | 4 (int) | **Heightmaps Size:** Size (in bytes) of the heightmaps NBT data. |
33+
| `heightmaps` | - | **Heightmaps:** A Compound NBT tag containing the heightmap data in the standard Minecraft format. |
34+
| `blockEntitiesSize` | 4 (int) | **Block Entities Size:** Size (in bytes) of the block entities NBT data. |
35+
| `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. |
36+
| `entitiesSize` | 4 (int) | **Entities Size:** Size (in bytes) of the entities NBT data. |
37+
| `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. |
38+
| `extraDataSize` | 4 (int) | **Extra Data Size:** Size (in bytes) of the extra data NBT data. |
39+
| `extraData` | - | **Extra Data:** A Compound NBT tag containing any additional chunk data. |
40+
41+
## 3. Section Format
42+
43+
The `sections` section from the Chunk Format is composed of individual section structures. Each section has the following format:
44+
45+
| Data Type | Size (Bytes) | Description |
46+
|-------------------|--------------|--------------------------------------------------------------------------------------------------------|
47+
| `hasSkyLight` | 1 (boolean) | **Has Sky Light:** `true` if sky light data is present, `false` otherwise. |
48+
| `skyLight` | 2048 | **Sky Light Data:** (Optional, present if `hasSkyLight` is `true`) 2048 bytes of sky light data. |
49+
| `hasBlockLight` | 1 (boolean) | **Has Block Light:** `true` if block light data is present, `false` otherwise. |
50+
| `blockLight` | 2048 | **Block Light Data:** (Optional, present if `hasBlockLight` is `true`) 2048 bytes of block light data. |
51+
| `blockStatesSize` | 4 (int) | **Block States Size:** Size (in bytes) of the block states NBT data. |
52+
| `blockStates` | - | **Block States:** A Compound NBT tag containing the block states data. |
53+
| `biomesSize` | 4 (int) | **Biomes Size:** Size (in bytes) of the biomes NBT data. |
54+
| `biomes` | - | **Biomes:** A Compound NBT tag containing the biome data. |
55+
56+
## Notes:
57+
58+
* "Minecraft format" for NBT tags refers to the standard NBT structure used by Minecraft for storing world data.
59+
* Boolean 1 stands for TRUE, boolean 0 stands for FALSE

slime-loader/src/main/java/net/roxymc/slime/loader/SlimeLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import static net.roxymc.slime.util.ObjectUtils.nonNull;
1616

1717
public class SlimeLoader {
18-
public static final byte[] SLIME_HEADER = new byte[]{-79, 11};
18+
public static final byte[] SLIME_HEADER = new byte[]{-79, 11}; // 0xB10B
1919

2020
private final Deserializers deserializers;
2121

slime-loader/src/main/java/net/roxymc/slime/serializer/SlimeSerializer_v12.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.io.IOException;
1818

1919
public class SlimeSerializer_v12 extends SlimeSerializer {
20-
public static final byte VERSION = 12;
20+
public static final byte VERSION = 12; // 0x0C
2121

2222
protected static final String TILE_ENTITIES = "tileEntities";
2323
protected static final String ENTITIES = "entities";

0 commit comments

Comments
 (0)