I am parsing a schematic file
with the following structure
The .schematic file format was created by the community to store sections of a Minecraft world for use with third-party programs. Schematics are in NBT format
The Named Binary Tag (NBT) file format is an extremely simple structured binary format used by the Minecraft game for a variety of things
Block Data Value
s define parts of the terrain in Minecraft.
I retrieving the block data
of every Minecraft Block, and need to figure out how to decode these bytes. This is an example for the Stairs
Minecraft Block
For example the stairs block data includes:
I can use nbt-js to parse the entire schematic file, which enables me to access the block data like this:
var b = schem.value.Data.value[index];
I decode the Stairs Block Data bits data with the following code
var facing = b & 0x03;
var half = (b >> 2) & 0x01;
var shape = (b >> 3) & 0x03;
These configuration values are essential to determine how the stair block should be rendered. For example, I use the facing value to rotate the block:
block.rotateX(facing);
However, the bits are interpreted differently for every block type, and this isn't defined anywhere that I can find.