twoolie / NBT

Python Parser/Writer for the NBT file format, and it's container the RegionFile.
MIT License
362 stars 74 forks source link

Update chunk.py #117

Closed mkuw closed 5 years ago

mkuw commented 5 years ago

I am not sure but it seems that the bitwise and should be a bitwise or. At least this fixes some problems I am encountering when plotting maps.

In particular, when the palette requires 5 bits entries, I am getting an artifact each 13 blocks. So each time the entry is written on two different longs of the state array.

Look at those chunk slices: after the fix image before the fix image

mfld-fr commented 5 years ago

Nice, you found the cause of these ugly plots on the map I was wondering about. Thank you !

macfreek commented 5 years ago

Thanks, @mkuw

@mfld-fr Any chance you can write a test for _init_index?

mfld-fr commented 5 years ago

Mmm... either that method is already covered by testing the map example on a recent world (as suggested in #113), OR we complement the get_block with a set_block + variable bit length encoding to have a read / write loop for a comprehensive unit test for all the possible lengths.

Personally, I don't need to write blocks, so I would not invest time in option 2. And for option 1, this PR demonstrates the map example is very attractive, so our kind users already do the job :wink:...