Hardware Reference
In-Depth Information
1.
In the LXTerminal window, type the following commands to create a new nano
text editor ile called
placeblock.py
:
cd mcpi/api/python
nano placeblock.py
2.
You need to import the
block
module from Minecraft Pi that allows you to use
the Minecraft block names. Type the following code into the nano
text editor
window:
import mcpi.minecraft as minecraft
import mcpi.block as block
mc = minecraft.Minecraft.create()
mc.setBlock(1, 10, 1, block.STONE)
he three numbers in the last line refer to the x, y and z coordinates (see Figure
6-4). his is followed by the block type you wish to use—
STONE
in this example
(Figure 6-6). he result in Minecraft Pi will be a single block of stone hanging in
the sky above the player.
3.
Press CTRL+X to exit nano, ensuring that you press y and Enter to save your
work. Test your code to see what happens.
FIGURE 6-6
Using
setBlock
in Minecraft Pi