wensheng / JuicyRaspberryPie

Programming Minecraft with Python (or JavaScript)!
BSD 2-Clause "Simplified" License
72 stars 28 forks source link

Wrong output type for mc.getBlock #12

Closed ashbork closed 2 years ago

ashbork commented 2 years ago

Edit: this is my mistake as I used the pip mcpi package. It could be more explicitly mentioned within the README.

When trying to access a block through mc.getBlock(x,y,z), the server returns a wrong data type, causing this traceback:

Traceback (most recent call last): File "x", line 5, in <module> print(mc.getBlock(1, 1, 1)) File ".../site-packages/mcpi/minecraft.py", line 344, in getBlock return int(self.conn.sendReceive(b"world.getBlock", intFloor(args))) ValueError: invalid literal for int() with base 10: 'SPRUCE_LEAVES'

The error occurs because the mcpi module tries to coerce the string that the server returned into an int.

This can be fixed by changing how mcpi itself works, but I think that's not the point of this project. I'm not sure if this is maintained but I think I do know how to implement a fix on the Python side (that'd require a 'custom' mcpi version).