Skip to content

World Format

This page will go over how Minecraft Worlds are organized and stored.

Hierarchy

Minecraft worlds have a hierarchy of how data can be accessed.

World -> Dimension/Level -> Region -> Chunk -> Block

TermDescription
WorldThe world that is to be loaded
DimensionThe dimension/level that is to be loaded
RegionA region covers a 32x32 chunk area, consisting of 512x128x512 blocks in total
ChunkA 16x128x16 area, containing 32.768 blocks in total

Everything before the region layer has remained the same ever since infinite world saving and loading has been introduced. Regions were introduced as part of the shift over to the McRegion format with Beta 1.3, up to today even, as the modern Anvil format is more or less just an extension of McRegion.

World Hierarchy Diagram

World

A world is a folder that contains everything that describes it, such as the overworld (region), the nether (DIM-1/region), the player data and level.dat.

Level

Level is what worlds were called in early Indev. As Minecraft shifted over to infinite terrain, the term World started to become more widely used, but for historical reasons the term Level stuck around. More specifically, due to how multiple dimensions are literally just separate worlds in separate folders (DIM-1 for the Nether), each dimension is technically its own separate Level.

Region

This is the core idea that differentiates the Alpha level format and McRegion. Instead of having a bunch of tiny files that only contain information about a single chunk, it's much more efficient to pack chunks together into 32x32 chunk regions.

Chunk

For more info, see the chunk page.

level.dat

level.dat is a gzip compressed nbt file which contains important metadata for the world.

FieldTypeDescription
LastPlayedLongTimestamp for when the world was last played
LevelNameString16The name of the world
rainingByteIf it's raining (see Weather)
rainTimeIntegerTime until raining is toggled (see Weather)
RandomSeedLongThe seed of the world
SizeOnDiskLongThe size of the world in bytes
SpawnXIntegerThe X-Coordinate of the Spawn
SpawnYIntegerThe Y-Coordinate of the Spawn
SpawnZIntegerThe Z-Coordinate of the Spawn
thunderingByteIf it's thundering (see Weather)
thunderTimeIntegerTime until thundering is toggled (see Weather)
TimeLongWorld time in ticks
versionIntegerlevel.dat format version. Always 19132 for worlds made after Beta 1.3

McRegion

McRegion is the format in which Minecraft Worlds were stored, starting with Beta 1.3 and ending with Release 1.1. This page will largely go into how exactly reading and writing of these files can be done, instead of going into many details such as alternative compression formats, as the article on the Minecraft Wiki already covers this quite thoroughly.

Reading

Reading is the easiest part of the McRegion format.

  1. Divide the chunk coordinate by 32 (or shift right by 5 bits) to get the region coordinate the chunk is in, following the naming convention r.x.z.mcr, where x and z are the region coordinates.
  2. Find the offset and sector count of the desired chunk data in the header by using 4 * ((x & 31) + (z & 31) * 32)
  3. Read the offset (3-bytes) and sector count (1-byte). These numbers should be multiplied by 4096, as each sector is 4 Kilobytes. Move to the offset.
  4. Get the length of the chunk data (4-bytes) and the compression type (1-byte). This is followed by length - 1 bytes of compressed data.
  5. Use the compression type to decompress the compressed data.
  6. Read the Chunks NBT Data

Further reading