Hardware Reference
In-Depth Information
pos = mc.player.getTilePos()
diffx = abs(pos.x - treasure_x)
diffy = abs(pos.y - treasure_y)
diffz = abs(pos.z - treasure_z)
diff = diffx + diffy + diffz
mc.postToChat("score:" + str(score) + " treasure:" +
str(diff))
Save and run your program and make sure that the homing beacon and score are
displayed on the Minecraft chat. Because you are still testing and developing your
program, the game loop is set to run 10 times slower than normal, so you should see
messages on the Minecraft chat every 10 seconds at the moment. Make sure this is
the case by counting from 1 to 10 in your head. You will still see some of the dummy
functions printing out on the Python Shell window every second for now, because
your program is not quite finished.
Adding Your Bridge Builder
You will now add the bridge builder from your earlier vanishingBridge.py pro-
gram. You only need to modify it a little, so that it checks whether your player is
standing on gold and, if not, creates a gold trail.
1. Make sure your buildBridge() function looks like the following. The impor-
tant lines that have changed from your vanishingBridge.py program are
marked in bold:
bridge = []
def buildBridge():
global score
pos = mc.player.getTilePos()
b = mc.getBlock(pos.x, pos.y-1, pos.z)
if treasure_x == None:
if len(bridge) > 0:
coordinate = bridge.pop()
mc.setBlock(coordinate[0], coordinate[1],
coordinate[2], block.AIR.id)
mc.postToChat("bridge:" + str(len(bridge)))
time.sleep(0.25)
 
 
Search WWH ::




Custom Search