Bedrock Edition level format

Bedrock Edition uses a modified version of Google's LevelDB, which uses the Zlib compression format for level storage.

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-mcpe, and the building instructions are documented by Tommaso at.

For a Java implementation of LevelDB + Zlib, see https://github.com/tinfoiled/leveldb

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  instead of 
 * 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 will compile and function 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 Nether, 2 for the End, omitted for the 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 NBT which stores the lengths and the multi-byte integer types in little-endian format, as opposed to the big-endian format used by 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.

Other keys
There's also the special key ~local_player for an entity data entry that holds the local player entity. If entity data exists here, it takes precedence over the player data stored in level.dat. The value associated with the ~local_player key is NBT encoded and only has 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 only has 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


 * VILLAGE_[0-9a-f\\-]+_DWELLERS
 * Consists mainly of an entity/mob ID's. Dwellers include villagers, iron golems, and cats.
 * VILLAGE_[0-9a-f\\-]+_INFO
 * Includes the village bounding box.
 * VILLAGE_[0-9a-f\\-]+_POI
 * Provides a mapping between villagers and work stations. Bed assignments do not appear to be stored.
 * VILLAGE_[0-9a-f\\-]+_PLAYERS

Other keys start with the following strings
 * actorprefix
 * digp
 * map_
 * portals
 * schedulerWT
 * structuretemplate
 * tickingarea

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.

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


 * Bedrock Edition level format/Entity format
 * Bedrock Edition level format/Entity format/Components
 * Bedrock Edition level format/Block entity format
 * Bedrock Edition level format/Item format
 * Bedrock Edition level format/Other data format

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 type of the file, which is 3 (was 2 before latest update) for level.dat. It is followed by another integer containing the length of the file, minus the header.

NBT Structure

 * World data.
 * The default permissions for players in the world.
 * 1 or 0 (true/false) - if the player can attack mobs.
 * 1 or 0 (true/false) - if the player can attack other players.
 * 1 or 0 (true/false) - if the player can build.
 * 1 or 0 (true/false) - true if the player is able to interact with redstone components.
 * 1 or 0 (true/false) - true if a player is flying.
 * 1 or 0 (true/false) - true if a player can break blocks instantly.
 * 1 or 0 (true/false) - if the hits can be landed on the player. If this is true, attempting to hit the player will behave the same as when they are in Creative mode.
 * 1 or 0 (true/false) - if an entity was struck by lightning.
 * 1 or 0 (true/false) - true if a player can fly.
 * 1 or 0 (true/false) - if the player can break blocks.
 * 1 or 0 (true/false) - if the player has operator commands.
 * 1 or 0 (true/false) - if the player is able to to open containers.
 * 1 or 0 (true/false) - if a player is allowed to teleport.
 * What permissions a player will default to, when joining a world.
 * What permissions a player has.
 * Defaults to 0.05.
 * Defaults to 0.1.
 * 1 or 0 (true/false) - true if the world is locked on experimental gameplay.
 * 1 or 0 (true/false) - true if the world has been saved with experiments on before.
 * ... Additional bytes for each experiment that Minecraft has/had.
 * 1 or 0 (true/false) - true if the bonus chest is enabled.
 * 1 or 0 (true/false) - true if the bonus chest has been placed in the world. Turning this to false will spawn another bonus chest near the spawn coordinates.
 * 1 or 0 (true/false) - if the output of command blocks will show in the chat of operators.
 * 1 or 0 (true/false) - true if the maps should be on a grid or centered to exactly where they are created. Default to 0.
 * 1 or 0 (true/false) - true if the command blocks are enabled.
 * 1 or 0 (true/false) - true if cheats are on.
 * 1 or 0 (true/false) - tells if the world has Platform-Specific texture packs or content. Used to prevent cross play in specific worlds, that use assets only allowed on specific consoles.
 * 1 or 0 (true/false) - true if force the player into the game mode defined in.
 * Is read-only.
 * 1 or 0 (true/false) - true if the world is created from a world template where the world options were intended not to be modified.
 * 1 or 0 (true/false) - true if the world is created from a world template.
 * 1 or 0 (true/false) - (unused) may cause world to not save, or delete after use. Seems to default back to false when a world is loaded.
 * 1 or 0 (true/false) - true if the world options cannot be modified until the user accepts that they are changing the map.
 * 1 or 0 (true/false) - true if a player will keep the items in their inventory after death.
 * 1 or 0 (true/false) - true if the "Position" message displaying the player's coordinates is shown.
 * 1 or 0 (true/false) - true if player death messages are shown in chat.
 * 1 or 0 (true/false) - true if player nametags are displayed.
 * 1 or 0 (true/false) - true if mobs can spawn.
 * Spawn pre-1.10.0 villagers.
 * 1 or 0 (true/false) - true if new players spawn with a locator map.
 * 1 or 0 (true/false) - true if the user must download the texture packs applied to the world to join.
 * 1 or 0 (true/false) - true if TNT can explode.
 * Whether the world is restricted to Microsoft Accounts only (players must be signed in).
 * The current difficulty setting. 0 is Peaceful, 1 is Easy, 2 is Normal, and 3 is Hard.
 * Marks a world as an Education Edition world (worlds with this set to 1 will not open on Bedrock!).
 * Maximum number of commands that can occur in one function. Limiting this may improve performance but will break some behaviour packs.
 * The dimension the player is in. 0 is the Overworld.
 * The default game mode of the player. 0 is Survival, 1 is Creative, 2 is Adventure, and 3 is Spectator.
 * The world type. 0 is Old, 1 is Infinite, and 2 is Flat.
 * The X coordinate where limited (old) world generation started.
 * The Y coordinate where limited (old) world generation started.
 * The Z coordinate where limited (old) world generation started.
 * The width (in chunks) of the borders surrounding the (old) world generation. Defaults to 16.
 * The depth (in chunks) of the borders surrounding the (old) world generation. Defaults to 16.
 * Maximum length of "Chain" command blocks that can be connected together. Some command blocks in links longer than the set limit will not function.
 * Defaults to 8. This is used to tell the game how many Overworld blocks go into one nether block (X blocks in the nether = 1 block in the overworld).
 * Seems to store the platform that the level is created on. Currently observed value is 2.
 * Defaults to 1.
 * Simulation distance.
 * The radius in which players are allowed to spawn near the world spawn point. The game may override this.
 * The X coordinate of the player's spawn position. Defaults to 0.
 * The Y coordinate of the player's spawn position. Defaults to 64.
 * The Z coordinate of the player's spawn position. Defaults to 0.
 * Version of Bedrock Edition Storage Tool, currently is 8.
 * Stores the Unix time stamp (in seconds) when the player saved the game.
 * Level seed.
 * Stores the current "time of day" in ticks. There are 20 ticks per real-life second, and 24000 ticks per Minecraft daylight cycle, making the full cycle length 20 minutes. 0 is the start of daytime, 12000 is the start of sunset, 13800 is the start of nighttime, 22200 is the start of sunrise, and 24000 is daytime again. The value stored in level.dat is always increasing and can be larger than 24000, but the "time of day" is always modulo 24000 of the "Time" field value.
 * Counts how many times the game has been closed since the world was created, with its value decreasing by 1 each time.
 * The version of Minecraft that is the maximum version to load resources from, (for example. Setting this to 1.16.0 removes any features that were added after version 1.16.0.
 * Makes the world into a single biome world and the biome set here is the biome of this single biome world.
 * JSON that controls generation of flat worlds. Default is.
 * Specifies the name of the world.
 * 1 or 0 (true/false) - true if the user must download the texture packs applied to the world to join.
 * 1 or 0 (true/false) - true if TNT can explode.
 * Whether the world is restricted to Microsoft Accounts only (players must be signed in).
 * The current difficulty setting. 0 is Peaceful, 1 is Easy, 2 is Normal, and 3 is Hard.
 * Marks a world as an Education Edition world (worlds with this set to 1 will not open on Bedrock!).
 * Maximum number of commands that can occur in one function. Limiting this may improve performance but will break some behaviour packs.
 * The dimension the player is in. 0 is the Overworld.
 * The default game mode of the player. 0 is Survival, 1 is Creative, 2 is Adventure, and 3 is Spectator.
 * The world type. 0 is Old, 1 is Infinite, and 2 is Flat.
 * The X coordinate where limited (old) world generation started.
 * The Y coordinate where limited (old) world generation started.
 * The Z coordinate where limited (old) world generation started.
 * The width (in chunks) of the borders surrounding the (old) world generation. Defaults to 16.
 * The depth (in chunks) of the borders surrounding the (old) world generation. Defaults to 16.
 * Maximum length of "Chain" command blocks that can be connected together. Some command blocks in links longer than the set limit will not function.
 * Defaults to 8. This is used to tell the game how many Overworld blocks go into one nether block (X blocks in the nether = 1 block in the overworld).
 * Seems to store the platform that the level is created on. Currently observed value is 2.
 * Defaults to 1.
 * Simulation distance.
 * The radius in which players are allowed to spawn near the world spawn point. The game may override this.
 * The X coordinate of the player's spawn position. Defaults to 0.
 * The Y coordinate of the player's spawn position. Defaults to 64.
 * The Z coordinate of the player's spawn position. Defaults to 0.
 * Version of Bedrock Edition Storage Tool, currently is 8.
 * Stores the Unix time stamp (in seconds) when the player saved the game.
 * Level seed.
 * Stores the current "time of day" in ticks. There are 20 ticks per real-life second, and 24000 ticks per Minecraft daylight cycle, making the full cycle length 20 minutes. 0 is the start of daytime, 12000 is the start of sunset, 13800 is the start of nighttime, 22200 is the start of sunrise, and 24000 is daytime again. The value stored in level.dat is always increasing and can be larger than 24000, but the "time of day" is always modulo 24000 of the "Time" field value.
 * Counts how many times the game has been closed since the world was created, with its value decreasing by 1 each time.
 * The version of Minecraft that is the maximum version to load resources from, (for example. Setting this to 1.16.0 removes any features that were added after version 1.16.0.
 * Makes the world into a single biome world and the biome set here is the biome of this single biome world.
 * JSON that controls generation of flat worlds. Default is.
 * Specifies the name of the world.
 * Stores the current "time of day" in ticks. There are 20 ticks per real-life second, and 24000 ticks per Minecraft daylight cycle, making the full cycle length 20 minutes. 0 is the start of daytime, 12000 is the start of sunset, 13800 is the start of nighttime, 22200 is the start of sunrise, and 24000 is daytime again. The value stored in level.dat is always increasing and can be larger than 24000, but the "time of day" is always modulo 24000 of the "Time" field value.
 * Counts how many times the game has been closed since the world was created, with its value decreasing by 1 each time.
 * The version of Minecraft that is the maximum version to load resources from, (for example. Setting this to 1.16.0 removes any features that were added after version 1.16.0.
 * Makes the world into a single biome world and the biome set here is the biome of this single biome world.
 * JSON that controls generation of flat worlds. Default is.
 * Specifies the name of the world.
 * JSON that controls generation of flat worlds. Default is.
 * Specifies the name of the world.
 * Specifies the name of the world.

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