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)
3
  • General programming questions belong on our larger parent site, Stack Overflow.
    – goldilocks
    Commented Sep 18, 2016 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
    Commented Sep 18, 2016 at 13:50
  • All apologies -- I was not aware of that.
    – goldilocks
    Commented Sep 18, 2016 at 13:56

3 Answers 3

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.

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

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).

0

Left wood door close

mc.setBlock(pos.x, pos.y, pos.z, 64, 1) mc.setBlock(pos.x, pos.y+1, pos.z, 64, 9)

Right wood door close

mc.setBlock(pos.x + 1, pos.y, pos.z, 64, 6) mc.setBlock(pos.x + 1, pos.y+1, pos.z, 64, 13)

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Mar 2, 2022 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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