I couldn’t find any information about the new biome storage format introduced in Bedrock 1.18, so I did some reverse engineering, and share the results to help others.
Bedrock 1.18 assigns a biome for each block, unlike Java, which assigns one to a 4x4x4 cube. Biome data for a whole chunk is stored in one LevelDB entry with the chunk key type 43 (0x2b), containing biome information for each subchunk.
Entry format:
- 512 bytes: seems to be a heightmap
- Paletted biome data for each subchunk from bottom to top
- 1 byte header
- bit 0: always 1 (?)
- bits 7..1: bits per value for the following array (can be 0 if the palette contains only one biome)
- 0xff indicates non-existent subchunk, in this case the following array and palette data are omitted
- n bytes: biome data for each block in the 16x16x16 subchunk in XZY order using the same aligned bit-packed int32 array format used for paletted block data. This array is omitted if the palette contains only one biome.
- 1 byte: biome palette length
- n * int32: biome palette entries (numeric biome IDs)
- 1 byte header
Brilliant!! Great work!!
I am working with 1.18.31 and it looks like the layout has changed slightly – the palette length seems to be an int32 now, and omitted when there is only 1 biome (header = 0x01)