When you try the example anvil_blockdata.py with a existing data array in a *.mca file, the following error raise in the print_chunklayer function:
ValueError: byte must be in range(0, 256)
Cause when a data array exist, the blocks array should be a short integer and not a bytearray anymore.
I fix it like this (do not forget to import array):
def print_chunklayer(blocks, data, add, yoffset):
blocks = array.array('h',blocks[yoffset*256:(yoffset+1)*256])
data = array_4bit_to_byte(data[yoffset*128:(yoffset+1)*128])
if add is not None:
add = array_4bit_to_byte(add[yoffset*128:(yoffset+1)*128])
for i,v in enumerate(add):
blocks[i] += 256*v
assert len(blocks) == 256
assert len(data) == 256
for row in grouper(zip(blocks,data), 16):
print (" ".join(("%4d:%-2d" % block) for block in row))
When you try the example anvil_blockdata.py with a existing data array in a *.mca file, the following error raise in the print_chunklayer function:
Cause when a data array exist, the blocks array should be a short integer and not a bytearray anymore. I fix it like this (do not forget to import array):