3

I have tried many times placing a door but all that seems to appear is the bottom half. How do I get the top half?

My python code is:

mc.setBlocks (10,11,16,10,10,16,64)
  • General programming questions belong on our larger parent site, Stack Overflow. – goldilocks Sep 18 '16 at 13:07
  • 1
    this is specific to the raspberry pi version of minecraft as it has a dedicated api that us not available on any other platform. Is this the right site? – Hippyjim Sep 18 '16 at 13:50
  • All apologies -- I was not aware of that. – goldilocks Sep 18 '16 at 13:56
5

You'll need to do it in two commands:

mc.setBlock(x, y, z, 64, 0)
mc.setBlock(x, y+1, z, 64, 8)

So, using your numbers, you would need:

mc.setBlock(10, 10, 16, 64, 0)
mc.setBlock(10, 11, 16, 64, 8)

Also, note that the sub-type for the blocks don't work if you use the named block types. So, for example, this won't work:

mc.setBlock(x, y, z, block.DOOR_WOOD, 0)
mc.setBlock(x, y+1, z, block.DOOR_WOOD, 8) #The 8 will be ignored

Although it's not documented anywhere, I assume that there are 8 states for the bottom of the door (0 - 7) corresponding to 4 directions closed and 4 directions opened. Then add 8 to the get the same direction for the top half of the door (8 - 15).

You can do something similar for other two part objects like beds.

  • It took a while to get back to this, but i confirmed it last night - spot on. – Hippyjim Dec 14 '16 at 9:19
0

The reason that the "8" will be ignored is that technically the setBlock() function takes a block id as the fourth argument (not a block). So if your fourth argument was block.DOOR_WOOD.id then the "8" will work.

As it is, by supplying the block type (rather than just its "id") means that Python takes the other attributes from the block and uses them as arguments - thus always using the default "0" for the "data" argument.

HTH. (NB: This /really/ confused me at first).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.