Difference between revisions of "Map Format"
(Region file format is a little bit more clear now.) |
|||
Line 165: | Line 165: | ||
===[region].mca=== | ===[region].mca=== | ||
− | Each region file is named "r.x.z.mca", where x and z are the coordinates. These coordinates are relative to each region. Given column coordinates, divide them by 32 to get the region coordinates. | + | Each region file is named "r.x.z.mca", where x and z are the coordinates. These coordinates are relative to each region. Given chunk column coordinates, divide them by 32 to get the region coordinates. [https://wiki.vg/Region_Files Region files] are not raw NBT files and must therefore be parsed differently see [https://wiki.vg/Region_Files Region files]. |
+ | Every generated chunk has a 5-byte header with the first four bytes as the length of the compressed chunk in bytes and the fifth byte as the compression scheme. | ||
− | + | {| class="wikitable" | |
− | + | |- | |
− | + | ! | |
− | + | !Length of the compressed<br />chunk in bytes | |
− | + | !Compression Scheme | |
− | + | |- | |
− | + | !Decoded | |
− | + | |5033 | |
− | + | |zlib | |
− | + | |- | |
− | + | !On Disk(in hex) | |
− | + | | <code>00 13 A9</code> | |
− | + | | <code>2</code> | |
− | + | |} | |
− | + | ||
− | + | The compression scheme can have two value: | |
− | + | {| class="wikitable" | |
− | + | |- | |
− | + | !Compression<br />Scheme | |
− | + | !Value | |
− | + | |- | |
− | + | |zlib | |
− | + | |<code>2</code> | |
− | + | |- | |
− | + | |gzip | |
− | + | |<code>1</code> | |
− | + | |} | |
− | + | ||
− | + | The notchian implementation will '''never''' compress with gzip but can read if provided. | |
− | + | ||
− | + | <pre> | |
− | + | TAG_Compound(''): 2 entries | |
− | + | { | |
− | + | TAG_Compound('Level'): 11 entries | |
− | + | { | |
− | + | TAG_List('Entities'): List of entities in the chunk column | |
− | + | { | |
− | + | TAG_Compound(): Each entity has a Tag_Compound | |
− | + | { | |
− | + | ... | |
+ | } | ||
+ | } | ||
+ | TAG_List('Sections'): 5 entries | ||
+ | { | ||
+ | TAG_Compound(''): 5 entries | ||
+ | { | ||
+ | TAG_Int('Y'): 0 | ||
+ | TAG_Byte_Array('BlockLight'): 2048 bytes | ||
+ | TAG_Byte_Array('Blocks'): 4096 bytes | ||
+ | TAG_Byte_Array('Data'): 2048 bytes | ||
+ | TAG_Byte_Array('SkyLight'): 2048 bytes | ||
+ | } | ||
+ | TAG_Compound(''): 5 entries | ||
+ | { | ||
+ | TAG_Int('Y'): 1 | ||
+ | TAG_Byte_Array('BlockLight'): 2048 bytes | ||
+ | TAG_Byte_Array('Blocks'): 4096 bytes | ||
+ | TAG_Byte_Array('Data'): 2048 bytes | ||
+ | TAG_Byte_Array('SkyLight'): 2048 bytes | ||
+ | } | ||
+ | ... | ||
+ | } | ||
+ | TAG_List('TileEntities'): See [https://minecraft.gamepedia.com/Chunk_format#Tile_entity_format Tile entity format] | ||
+ | TAG_Long('InhabitedTime'): 16 | ||
+ | TAG_Long('LastUpdate'): Last time a block changed in this column | ||
+ | TAG_Byte('LightPopulated'): Is the light calculated | ||
+ | TAG_Byte('TerrainPopulated'): Has the terrain been generated | ||
+ | TAG_Int('xPos'): X position of the region. Each single increment to x is 512 blocks | ||
+ | TAG_Int('yPos'): Y position of the region. Each single increment to y is 512 blocks | ||
+ | TAG_Byte_Array('Biomes'): 256 bytes // Note: Biomes affect blocks in 1x256x1 columns | ||
+ | TAG_Int_Array('HeightMap'): 256 bytes | ||
+ | } | ||
+ | TAG_Int('DataVersion'): 1343 | ||
+ | } | ||
+ | </pre> | ||
=== See also === | === See also === |
Revision as of 19:56, 20 September 2020
This page covers the world information as of 1.2.5 to the present. See Alpha Map Format for Alpha information.
Contents
General Information
Worlds are represented as a series of regions, within which are a number of columns, and chunks. Each region is 32x1x32 columns, each column is 1x16x1 chunks, and each chunk is 16x16x16 blocks. The overall block height of a column is 256. Each chunk stores four (or five) things - block IDs (8-bit), block metadata (4-bit), block light (4-bit), and sky light (4-bit). The optional fifth value is "add" data, which is four bits to be added to block IDs for additional block ID support (not used in vanilla Minecraft). Block light is light cast by things like torches and glowstone, and is calculated with a 3D Flood Fill algorithm. Sky light is the light cast by the sky, and is calculated by starting at the top and working your way down. As you pass through semi-transparent blocks, you decrease the lighting value until you hit an opaque block. The opaque block is the last block whose skylight has a nonzero value. Lighting starts at 0xF (brightest) and works down to 0x0 (dimmest). Columns store biome information. Each 1x256x1 cuboid of blocks has the same biome value, for a total of 256 possible biome values per chunk (16x16). Biome values are stored as bytes.
Biome Values
Name | Value |
---|---|
Ocean | 0 |
Plains | 1 |
Desert | 2 |
Extreme Hills | 3 |
Forest | 4 |
Taiga | 5 |
Swampland | 6 |
River | 7 |
Hell | 8 |
Sky | 9 |
Frozen Ocean | 10 |
Frozen River | 11 |
Ice Plains | 12 |
Ice Mountains | 13 |
Mushroom Island | 14 |
Mushroom Island Shore | 15 |
Beach | 16 |
Desert Hills | 17 |
Forest Hills | 18 |
Taiga Hills | 19 |
Extreme Hills Edge | 20 |
Jungle | 21 |
Jungle Hills | 22 |
Storage
This section documents the Anvil format for servers.
Maps are stored as a specific directory structure with several NBT files within. For the sake of examples, the world we'll be working with is stored in a folder called "/world".
Directory Structure
- /world/data: Unused
- /world/DIM-1: Nether world
- /world/DIM-1/region: Nether world regions
- /world/DIM1: End world
- /world/DIM1/region: End world regions
- /world/players: Player data
- /world/region: Overworld regions
level.dat
In the root directory is a level.dat file. The structure of that file is this:
- NBTCompound(Data)
- NBTByte(hardcore)
- NBTByte(MapFeatures): Set to 1 if structures are generated, such as villages
- NBTByte(raining): Set to 1 if currently raining
- NBTByte(thundering): Set to 1 if currently thundering (only if there is potential for thunder, not if a thunderbolt is currently in progress)
- NBTInt(GameType)
- NBTInt(generatorVersion): 0 for 1.2.5
- NBTInt(rainTime): The ticks remaining until rain stops?
- NBTInt(SpawnX)
- NBTInt(SpawnY)
- NBTInt(SpawnZ)
- NBTInt(thunderTime)
- NBTInt(version): 19133 for 1.2.5
- NBTLong(LastPlayed)
- NBTLong(RandomSeed)
- NBTLong(SizeOnDisk): Always 0 for 1.2.5
- NBTLong(Time)
- NBTString(generatorName)
- NBTString(LevelName)
[playeruuid].dat
Each player that has ever connected is given a [playeruuid].dat file.
- NBTCompound
- NBTByte(OnGround)
- NBTByte(Sleeping)
- NBTShort(Air)
- NBTShort(AttackTime)
- NBTShort(DeathTime)
- NBTShort(Fire): Ticks until the player is no longer on fire, or zero
- NBTShort(Health)
- NBTShort(HurtTime)
- NBTShort(SleepTimer)
- NBTInt(Dimension)
- NBTInt(foodLevel)
- NBTInt(foodTickTimer)
- NBTInt(playerGameType)
- NBTInt(XpLevel)
- NBTInt(XpTotal)
- NBTFloat(FallDistance)
- NBTFloat(foodExhastionLevel)
- NBTFloat(foodSaturationLevel)
- NBTFloat(XpP)
- NBTCompound(Inventory)
- NBTCompound
- NBTByte(Count)
- NBTByte(Slot)
- NBTShort(Damage): Damage -or- metadata
- NBTShort(id)
- NBTCompound
- NBTList(Motion)
- NBTDouble
- NBTDouble
- NBTDouble
- NBTList(Pos)
- NBTDouble
- NBTDouble
- NBTDouble
- NBTList(Rotation)
- NBTFloat
- NBTFloat
[region].mca
Each region file is named "r.x.z.mca", where x and z are the coordinates. These coordinates are relative to each region. Given chunk column coordinates, divide them by 32 to get the region coordinates. Region files are not raw NBT files and must therefore be parsed differently see Region files. Every generated chunk has a 5-byte header with the first four bytes as the length of the compressed chunk in bytes and the fifth byte as the compression scheme.
Length of the compressed chunk in bytes |
Compression Scheme | |
---|---|---|
Decoded | 5033 | zlib |
On Disk(in hex) | 00 13 A9
|
2
|
The compression scheme can have two value:
Compression Scheme |
Value |
---|---|
zlib | 2
|
gzip | 1
|
The notchian implementation will never compress with gzip but can read if provided.
TAG_Compound(''): 2 entries { TAG_Compound('Level'): 11 entries { TAG_List('Entities'): List of entities in the chunk column { TAG_Compound(): Each entity has a Tag_Compound { ... } } TAG_List('Sections'): 5 entries { TAG_Compound(''): 5 entries { TAG_Int('Y'): 0 TAG_Byte_Array('BlockLight'): 2048 bytes TAG_Byte_Array('Blocks'): 4096 bytes TAG_Byte_Array('Data'): 2048 bytes TAG_Byte_Array('SkyLight'): 2048 bytes } TAG_Compound(''): 5 entries { TAG_Int('Y'): 1 TAG_Byte_Array('BlockLight'): 2048 bytes TAG_Byte_Array('Blocks'): 4096 bytes TAG_Byte_Array('Data'): 2048 bytes TAG_Byte_Array('SkyLight'): 2048 bytes } ... } TAG_List('TileEntities'): See [https://minecraft.gamepedia.com/Chunk_format#Tile_entity_format Tile entity format] TAG_Long('InhabitedTime'): 16 TAG_Long('LastUpdate'): Last time a block changed in this column TAG_Byte('LightPopulated'): Is the light calculated TAG_Byte('TerrainPopulated'): Has the terrain been generated TAG_Int('xPos'): X position of the region. Each single increment to x is 512 blocks TAG_Int('yPos'): Y position of the region. Each single increment to y is 512 blocks TAG_Byte_Array('Biomes'): 256 bytes // Note: Biomes affect blocks in 1x256x1 columns TAG_Int_Array('HeightMap'): 256 bytes } TAG_Int('DataVersion'): 1343 }