-
Notifications
You must be signed in to change notification settings - Fork 85
Level format
The level format is entirely compressed with GZip, so you must first decompress the file.
Note: As the uncompressed data can be very large, it is recommended you decompress via a streaming approach instead of entirely at once.
Note: This format is an extension of the MCSharp/MCZall/MCLawl/MCForge level format, and is forwards compatible with reader software for these formats.
2 | Identifier (must be 1874)
2 | Width of the map
2 | Length of the map
2 | Height of the map (vertical)
2 | Spawn X coordinate
2 | Spawn Z coordinate
2 | Spawn Y coordinate (vertical)
1 | Spawn horizontal orientation (yaw)
1 | Spawn vertical orientation (pitch)
1 | Min access permission, internally ignored (do not read if identifier is not 1874)
1 | Min build permission, internally ignored (do not read if identifier is not 1874)
var | raw blocks of the map, 1 byte each (number of blocks is width x height x length)
Note: The block id 163 has a special meaning.
It means that the block is a custom block, and that its actual/real id can be found by looking up the custom blocks sparse array at the given coordinates.
Custom block ids are represented as a sparse array, consisting of groups of 16x16x16 sections. This is done to minimise memory usage.
1 | 0xBD, means data follows (if not 0xBD, or already end of stream, stop reading)
for (y = 0; y < ceil(height / 16); y += 1)
for (z = 0; z < ceil(length / 16); z += 1)
for (x = 0; x < ceil(width / 16); x += 1)
{
1 | 1 if this section has data, any other value means it is empty and is skipped
4096| Custom block ids for this section
}
There are a variable number of sections which can be read up to the end of stream.
Each section is identified by a unique byte.
This section contains persistent data for physics (e.g. time until revert, drop chance, etc), that allows for physics to be properly resumed when a level is loaded again.
1 | 0xFC, means the section is a physics data section
4 | number of entries
var | Each entry is two four-byte integers. (first is position index, second is raw data)
position index may be unpacked as follows:
x = (index % width);
y = (index / width) / length;
z = (index / width) % length;
raw data for an entry is laid out according to this structure