Hardware Reference
In-Depth Information
DIGGING INTO THE CODE
Until now, you have used the position of the player as a starting point for inter-
acting blocks; this allows you to ind out what block the player is standing on or
place blocks around the player. However, this poses a problem if you want to
place multiple blocks. The x, y and z coordinates returned by the getPos()
function are decimals (also known as loats ), as your player can be in the middle
of a block in Minecraft—but to interact with blocks you need to use whole num-
bers (aka integers ). So instead, use the function getTilePos() , which returns
the block (or tile) that the player is standing on.
CHALLENGE
Try changing the values for the block coordinates and see what cubes and
cuboids (rectangular cubes) you can make. See Figure 6-7 if you need some
guidance.
How might you use setBlocks to build a wall?
FIGURE 6-7 Using setBlocks to make a cube in Minecraft Pi
Search WWH ::




Custom Search