Hardware Reference
In-Depth Information
he time delays are important in this code, so that you can move the player
around the Minecraft world before the transporter blocks are placed.
4. Place a diamond block as the irst transporter location, underneath the player's
position:
transporter1 = mc.player.getTilePos()
mc.setBlock(transporter1.x, transporter1.y - 1, ;
transporter1.z, block.DIAMOND_BLOCK)
mc.postToChat(“1st Transporter created”)
time.sleep(2)
5. Display a message on the screen to tell the player to move and ind the second
location where he wants to be able to transport to and from:
mc.postToChat(“Find another location in 30 seconds”)
time.sleep(30)
transporter2 = mc.player.getTilePos()
mc.setBlock(transporter2.x, transporter2.y -1, ;
transporter2.z, block.DIAMOND_BLOCK)
mc.postToChat(“2nd Transporter created”)
time.sleep(2)
6. Create a while true loop to continually check the player's position. If the
player is positioned on the irst transporter diamond block location, her location
will be changed to where the second diamond block is located. If the player is
positioned on the second transporter diamond block location, her location will
be changed to where the irst diamond block is located.
while (True):
time.sleep(1)
pos = mc.player.getTilePos()
if(pos.x == transporter1.x) and (pos.y == ;
transporter1.y) and (pos.z == transporter1.z):
mc.player.setPos(transporter2.x, transporter2.y, ;
transporter2.z)
if(pos.x == transporter2.x) and (pos.y == ;
transporter2.y) and (pos.z == transporter2.z):
mc.player.setPos(transporter1.x, transporter1.y, ;
transporter1.z)
Figure 6-8 shows the code, and Figure 6-9 shows the diamond transporter in position.
Search WWH ::




Custom Search