Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anvil_blockdata.py raise a ValueError #83

Closed
psolyca opened this issue Apr 12, 2015 · 1 comment
Closed

anvil_blockdata.py raise a ValueError #83

psolyca opened this issue Apr 12, 2015 · 1 comment

Comments

@psolyca
Copy link
Contributor

psolyca commented Apr 12, 2015

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))
macfreek added a commit that referenced this issue Apr 15, 2015
Fix issue #83 in examples/anvil_blockdata.py
@macfreek
Copy link
Collaborator

Fixes with pull request #84.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants