I am currently making a Minecraft chunk manipulation program, and I would like to know how Minecraft chunk sections are stored.
From the Minecraft Wiki Article on how Minecraft Stores its chunks.
Sections: List of Compound tags, each tag is a sub-chunk of sorts.
An individual Section.
Y: The Y index (not coordinate) of this section. Range 0 to 15 (bottom to top), with no duplicates but some sections may be missing if empty.
Blocks: 4096 bytes of block IDs defining the terrain. 8 bits per block, plus ? the bits from the below Add tag.
Add: May not exist. 2048 bytes of additional block ID data. The value to add to (combine with) the above block ID to form the true block ID in the range 0 to 4095. 4 bits per block. Combining is done by shifting this value to the left 8 bits and then adding it to the block ID from above.
Data: 2048 bytes of block data additionally defining parts of the terrain. 4 bits per block.
BlockLight: 2048 bytes recording the amount of block-emitted light in each block. Makes load times faster compared to recomputing at load time. 4 bits per block.
SkyLight: 2048 bytes recording the amount of sunlight or moonlight hitting each block. 4 bits per block.
But I do not understand how Blocks
is read. Every Section in a Chunk is 16 x 16 x 16 blocks. But instead Minecraft stores the blocks in a section in a 1-d array.