Hardware Reference
In-Depth Information
You'll see there is an extra number at the end of
setBlocks()
. This number
sets the colour of the carpet; in this case, it is number 14, which is red. This is
explained in the following Digging into the Code sidebar.
Save your program, then move to somewhere in your Minecraft world where there is a
bit of space and run your program by choosing Run
➪
Run Module from the menu. You
should see your house miraculously materialise in front of your eyes! Walk inside and
explore it. Look up at the roof and through the windows, and marvel at how quickly
you built this house from scratch! (See Figure 3-6.)
Don't forget that
buildHouse.py
always builds the house relative to your player's
position. Move around the Minecraft world and run
buildHouse.py
again to build
another house. You can build houses all over your Minecraft world—how cool is that?
FIGURE.3-6
This house was built automatically by a Python program.
DIGGING INTO THE CODE
When you built your carpet, you used an extra number with
setBlocks()
:
mc.setBlocks(x1, y1, z1, x2, y2, z2, block.WOOL.id,
14
)
Let's dig into that and work out what it means.
WOOL
is a really interesting block type, because it has what is called “extra data .
This means that not only can you ask for the block to be wool but you can also
use this extra data to change the appearance of the
WOOL
block. There are other