How to decode Data (ie block state) bytes in Minecraft schematic (nbt) file?


April 2019


90 time


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 Values define parts of the terrain in Minecraft.

I am trying to retrieve the block data of every Minecraft Block. This is an example for the Stairs Minecraft Block

For example the stairs block data includes:

enter image description here

I can use nbt-js to parse the data field:

var b = schem.value.Data.value[index];

I decode the Stairs Block Data bits data with the following code

var facing = data & 0x03;
var half = (data >> 2) & 0x01;
var shape = (data >> 3) & 0x03;

0 answers