Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Bedrock Edition level format

From SAS Gaming Wiki

Template:Exclusive Template:Cleanup

Bedrock Edition uses a modified version of Google's LevelDB, which uses the Zlib compression format for Minecraft:world storage. The world storage files are located in a world file in Minecraft:com.mojang.

LevelDB based format

Mojang variant LevelDB format

Mojang has modified Google's Original LevelDB to add Zlib compression and Windows support. The code is available at https://github.com/Mojang/leveldb, and the building instructions are documented by Tommaso at Template:Tweet.

For a Java implementation of LevelDB + Zlib, see https://github.com/HiveGamesOSS/leveldb-mcpe-java

Google's leveldb library has evolved extensively since Mojang released their version, but the Mojang version still works (as of 2022). The code does require some minor tweaks to compile:

  • db/snappy_compressor.cc should refer include <snappy.h> instead of <snappy/snappy.h>
  • table/table_test.cc contains two references to snappy that are unresolvable but irrelevant. port::Snappy_Compress and leveldb::SnappyCompressor. If these are simply commented out, the rest compiles and functions properly.

The database is stored in the db/ subdirectory of a Bedrock Edition world. The database path which is passed to the LevelDB API is this directory path, not the path to any file within it. It seems this is also where terrain generation is stored. This is because you can turn an old world infinite by replacing its db folder with one from an infinite world.

Chunk key format

A database key for data regarding a chunk is the concatenation of:

  • Two signed 32-bit little-endian integers (x and z in chunk coordinates, respectively),
  • An optional third 32-bit little-endian integer (1 for the Minecraft:Nether, 2 for the Minecraft:End, omitted for the Minecraft:Overworld),
  • A one-byte tag specifying the type of record represented by the key (see table), and
  • (for a "SubChunkPrefix" record) a one-byte subchunk index (from 0 to 15).

Accordingly, such a key may be 9, 10, 13 or 14 bytes long. Not all subchunks necessarily exist for a given chunk.

The "BlockEntity", "Entity" and "PendingTicks" records are represented by a sequence of concatenated root tags in a variant of Minecraft:NBT which stores the lengths and the multi-byte integer types in little-endian format, as opposed to the big-endian format used by Template:El or the original NBT specification.

The value 0 is used in the "Version" record in old style worlds; higher values are used in infinite worlds.

Key type tags
Tag byte Name Structure Description
Dec Hex ASCII
43 2B + Data3D Heightmap (256×2 bytes)

Biome data (varying lengths)

Biomes are stored as palettes similar to blocks. Exactly 25 palettes are written. Biome IDs are written as integers.
44 2C , Version 1 byte A byte
45 2D - Data2D Heightmap (256×2 bytes)

2D biomes (256×1 bytes)

Biome IDs are written as 8-bit integers. No longer written since v1.18.0.
46 2E . Data2DLegacy Heightmap (256×2 bytes)

2D biomes (256×4 bytes)

Each entry of the biome array contains a biome ID in the first byte, and the final 3 bytes are red/green/blue respectively. No longer written since v1.0.0.
47 2F / SubChunkPrefix Subchunk version (1 byte) Version-dependent data Terrain for a 16×16×16 subchunk
48 30 0 LegacyTerrain Block IDs (32768 bytes)

Block meta (32768 nibbles)

Block sky light (32768 nibbles)

Block light (32768 nibbles)

Heightmap (256×1 bytes)

2D biomes (256×4 bytes)

Data ordered in XZY order, unlike Java.

No longer written since v1.0.0.

Biomes are IDs plus RGB colours similar to Data2DLegacy.

49 31 1 BlockEntity List of NBT compound roots Minecraft:Block entity data (little-endian NBT)
50 32 2 Entity List of NBT compound roots Minecraft:Entity data (little-endian NBT)
51 33 3 PendingTicks NBT compound root Pending tick data (little-endian NBT)
52 34 4 LegacyBlockExtraData Entry count (4 bytes)

Entries: Key (4 bytes), Value (2 bytes).

Array of blocks that appear in the same place as other blocks. Used for grass appearing inside snow layers prior to v1.2.13. No longer written as of v1.2.13.
53 35 5 BiomeState
54 36 6 FinalizedState 4 bytes A 32-bit little endian integer
55 37 7 ConversionData No longer used
56 38 8 BorderBlocks Education Edition Feature
57 39 9 HardcodedSpawners Bounding boxes for structure spawns stored in binary format
58 3A : RandomTicks NBT compound root Random tick data (little-endian NBT)
59 3B ; Checksums xxHash checksums of other chunk records. No longer written as of v1.18.0.
61 3D = MetaDataHash
61 3E > GeneratedPreCavesAndCliffsBlending Not used
63 3F ? BlendingBiomeHeight Not used
64 40 @ BlendingData
65 41 A ActorDigestVersion
118 76 v LegacyVersion 1 byte Moved to 44 in v1.16.100
119 77 w AABBVolumes

Other keys

There's also the special key ~local_player for an entity data entry that holds the local player entity. The value associated with the ~local_player key is NBT encoded and has only a single compound tag at the root level.

There's also a special key for remote players which consists of two parts. The first part is the prefix "player_" (without the quotes) and the second part is the client ID which is contained in the remote player's clientid.txt file. For example, player_-12345678 would be the key for a remote client with an client ID of -12345678. The value associated with the "player_" prefixed key is NBT encoded and has only a single compound tag at the root level.

There's also a special "game_flatworldlayers" key of length 20 for flat worlds. The value associated with this key is a set of numbers in ASCII text format. An example of a value associated with the "game_flatworldlayers" key is "[7,3,3,2]" where the value length for this example is 9.

There are several keys related to villages. Depending on the dimension, the village key is prefixed with VILLAGE_DIMENSION_[0-9a-f\\-]+_, with DIMENSION being replaced with the dimension's name.

  • DWELLERS
    • Consists mainly of an entity/mob ID's. Dwellers include villagers, iron golems, and cats.
  • INFO
    • Includes the village bounding box.
  • POI
    • Provides a mapping between villagers and their beds, village center (bell) and work station.
  • PLAYERS

Other keys start with the following strings

  • actorprefix
  • digp
  • map_
  • portals
  • schedulerWT
  • structuretemplate
  • tickingarea
  • DynamicProperties
  • scoreboard
  • Overworld
  • Nether
  • TheEnd
  • AutonomousEntities
  • BiomeData
  • mobevents
  • LevelChunkMetaDataDictionary
  • RealmsStoriesData_
  • DedicatedServerForcedCorruption
  • SST_SALOG
  • SST_WORD
  • SST_WORD_

An official explanation from Microsoft about how entities (actors) are stored in LevelDB can be found on Microsoft Learn / Minecraft Bedrock Edition.

Sample parsers of Bedrock level-db

  • An example implementation of a Bedrock level-db parser can be found in minecraft_mmccoo. This implementation walks the NBTs of all block, entities/mobs, elevations, and village related items.
  • A TypeScript implementation can be found on the mcbe-leveldb NPM package.

NBT structures

The following articles document NBT structures of block entity and entity.

level.dat

The level.dat is still in uncompressed NBT format. The file begins with an 8-byte header, consisting of a little-endian 4-byte integer indicating the version of the file, which is currently 10. It is followed by another integer containing the length of the file, minus the header.

NBT Structure

LOG

The LOG files are located at the /db path of a level, and are part of the leveldb format, used in between compaction of the LDB files. It is similar to a Log file for a program. The format is:

YYYY/MM/DD-Hour/Minute/Second.StepName "Info"

Example:

2014/07/24-22:20:08.400488 4a3638 Recovering log #3

History

Template:HistoryTable

See also

References

Template:Reflist

Navigation

Template:Navbox Bedrock Edition

Minecraft:de:Spielstand-Speicherung (Bedrock) Minecraft:es:Formato de nivel de Bedrock Edition Minecraft:ja:Levelフォーマット/Bedrock Edition Minecraft:nl:Bedrockeditie level format Minecraft:pt:Formato de nível da Edição Bedrock Minecraft:zh:基岩版存档格式