Lesson 16: Boom

Escape the villagers


After escaping the dark maze we will now write a program that sets off TNT as we run past the bridge taking out the temple villagers following us.


# DETONATE
import mcpi.minecraft as minecraft
import mcpi.block as block

mc = minecraft.Minecraft.create()
playerPos = mc.player.getPos()

mc.setBlock(playerPos.x,playerPos.y,playerPos.z+2,152)

while (True):

	mc.postToChat("Run!")
	playerPos = mc.player.getPos()

	standBlock = mc.getBlock(playerPos.x,playerPos.y-1,playerPos.z)

	if standBlock == 57:
		mc.postToChat("KEEP RUNNING Its going to blow!!!")
		mc.setBlock(playerPos.x,playerPos.y-1,playerPos.z,152)
		break