Alpha Level Format

From Minecraft Wiki
Jump to: navigation, search

Minecraft infdev introduced a new data storage challenge while under development: Terrain generated in infdev has the potential to be almost 235 petabytes, which is 240,640 terabytes, in size when stored in memory, due to the sheer size of the map (several times the surface area of the Earth). Therefore, to reduce file size and memory usage, Notch decided to split the terrain into 16 x 16 x 128 chunks and store them on disk when not visible. In addition, terrain is only generated when it is within the drawing distance of the player's camera, significantly reducing save size, since most players will only be able to search a tiny fraction of the map in a reasonable time frame.

Contents

[edit] World folder structure

An infdev level is actually a single folder containing at least one file named level.dat. The folder may also contain level.dat_old, a backup of level.dat. There is also a session.lock file to make sure only one Minecraft opens the world at once.

The world folder may have up to 64 subfolders, each with up to 64 additional subfolders each. These folders contain the chunk files that hold the world's terrain and entities. Each chunk file is identified by its chunk position xPos and zPos. The varying parts of the chunk file's name are obtained by taking the base36 representation of the xPos and zPos. The names of the folders that the chunk file is placed in are found by taking xPos and zPos, modulo 64 (or bitwise ANDing with 63), and converting to base36. Negative coordinates must be interpreted as positive numbers, bitwise, via two's complement. So, -13 is treated as 243 (if its size is a byte).

As an example, to find the chunk at position (-13, 44):

* The first folder name is base36(-13 % 64). This is base36(243 % 64 = 51) which is "1f".
* The second folder name is base36(44 % 64). This is base36(44) which is "18".
* The chunk file's name is "c." + base36(-13) + "." + base36(44) + ".dat". This evaluates to "c.-d.18.dat"
* Thus, the chunk at (-13, 44) is stored in "1f/18/c.-d.18.dat"

Each chunk remembers its position independently of the file and folder names. See Chunk format to find out how to read a chunk's position from the file data.

As of Beta 1.3, this scheme has been replaced by chunks grouped in region files.

[edit] Dimensions

Dimensions are saved in the same way normal worlds are, but instead of mixing the world files inside the save folder, the files are stored in an additional sub-folders with their own region and chunk data. Their names start with DIM, followed by the dimension ID.

These dimension IDs are known so far:

ID Folder Dimension
0 saves/[World]/ Normal world (Overworld), always stored in the world folder without DIM
-1 saves/[World]/DIM-1/ The Nether, added with the Halloween Update
1 saves/[World]/DIM1/ The End, added with 1.9-pre4

[edit] session.lock Format

session.lock contains the timestamp of when the world was last touched. The file is eight bytes long, and contains a single 64-bit signed integer in big endian format. The value of this integer is the timestamp, stored as the number of milliseconds elapsed since 1970, in UTC.

Unlike typical lock files, session.lock ensures that the LAST program to open a world is that one that owns it. The process goes something like this:

  1. program opens session.lock
  2. program writes timestamp to session.lock
  3. program monitors session.lock for changes
  4. if the contents of session.lock change, program aborts and gives up its lock on the world.

[edit] level.dat Format

level.dat is a GZipped NBT file that stores environmental data (time of day, for example) and player health, inventory, velocity, and position within the map. Most importantly, it stores the Random Seed that the terrain generator uses to seamlessly generate more terrain on the fly.

The world folder may also contain a second file, level.dat_old, a backup of level.dat.

[edit] NBT Structure

The structure of the file is as follows:

[edit] See Also

Personal tools
Namespaces
Variants
Actions
Minecraft Wiki
Minecraft
Toolbox
In other languages

Recent Community Articles

Mojang Tweets

    Getting your tweets...