Hardware Reference
In-Depth Information
When you run this code, the player will suddenly change position. he last line of
code— mc.player.setPos(pos.x, pos.y + 60, pos.z) —adds 60 only to the
y axis (up and down). he result is that the player is suddenly transported from her
current position to the middle of the sky—and because the player has nothing to stand
on, she starts to fall! In the next section, you'll discover how to give your player some-
thing to stand on.
FIGURE 6-5 Using getPos and setPos to locate and move a player in Minecraft Pi
Placing a Block
Traditionally, Minecraft is played by building structures such as shelters, homes and
other buildings. In fact, you can build whole cities if you are good at the game and have
spent lots of time farming and creating the diferent levels of material blocks. However,
if you use a version of Minecraft that you can manipulate with code, you don't need to
spend hours building a structure; you can simply program it to happen.
Before you start this section, it is important that you create a new world in
Minecraft Pi by clicking on the Create New button after starting the game from
the title menu. This will place the player at the home position. If you do not do
this, you might not be able to see the blocks you create in the next section.
Search WWH ::




Custom Search