Hardware Reference
In-Depth Information
FIGURE.8-4
Block positions of wooden horse Minecraft shape
Now you're going to create a program that uses
MinecraftShape
to create the wooden
horse in Figure 8-4 and make it move:
1.
Open IDLE, and click File
➪
New File to create a new program. Save the file as
WoodenHorse.py
in the
MyAdventures
folder.
2.
Import the
minecraft
,
block
,
minecraftstuff
and
time
modules:
import mcpi.minecraft as minecraft
import mcpi.block as block
import mcpi.minecraftstuff as minecraftstuff
import time
3.
Create the
Minecraft
object:
mc = minecraft.Minecraft.create()
4.
Create the wooden horse shape by creating a list of blocks using
ShapeBlock
to
define the relative position and block type of each block:
horseBlocks = [
minecraftstuff.ShapeBlock(0,0,0,block.WOOD_PLANKS.id),
minecraftstuff.ShapeBlock(-1,0,0,block.WOOD_PLANKS.id),
minecraftstuff.ShapeBlock(1,0,0,block.WOOD_PLANKS.id),
minecraftstuff.ShapeBlock(-1,-1,0,block.WOOD_PLANKS.id),