Hardware Reference
In-Depth Information
You can then use setBlocks , adding the coordinates of the player's location to indi-
cate where you would like the blocks to be placed:
mc.setBlocks(pos.x, pos.y, pos.z, pos.x + 10, ;
pos.y + 10, pos.z + 10, block.MELON)
You may ind that you end up inside this cube because the irst set of coordinates is the
player's position! You could change the location coordinates in the same way:
mc.setBlocks(pos.x + 5, pos.y + 5, pos.z, pos.x + 10, ;
pos.y + 10, pos.z + 10, block.MELON)
Try this yourself by modifying your existing code, and see if you can get it to work.
Creating a Diamond
Transporter
When you are playing Minecraft in build mode, it takes a lot of time to move from one
side of the world to the other. You can speed things up by creating a diamond block
transporter to whisk you from location to location. To do this, you will use set Block ,
getPos and setPos .
To see a tutorial for diamond transporter program, visit the companion website
at www.wiley.com/go/adventuresinrp . Click the Videos tab and select the
DiamondTransporter ile.
1. In the LXTerminal window, type the following code to create a new nano text
editor ile called transporter.py :
cd mcpi/api/python
nano transporter.py
2. Import the modules that you will need:
import mcpi.minecraft as minecraft
import mcpi.block as block
import time
3. Set up the connection to Minecraft and post a message to the screen:
mc = minecraft.Minecraft.create()
mc.postToChat(“A Transporter Adventure”)time.sleep(5)
Search WWH ::




Custom Search