Lesson 4: Dig, dig, dig!

Turning Sand into Air !


Now we will code our first automated program. We will learn about program loops and conditions to take a block and turn it into another block!


#SAND REMOVER
import mcpi.minecraft as minecraft
import mcpi.block as block
mc = minecraft.Minecraft.create()
while(True):
	playerPos = mc.player.getPos()
	standBlock = mc.getBlock(playerPos.x,playerPos.y-1,playerPos.z)
	frontBlock = mc.getBlock(playerPos.x,playerPos.y,playerPos.z-1)
	if frontBlock == 12:
		mc.setBlock(playerPos.x,playerPos.y,playerPos.z-1,block.AIR)
	if standBlock == 57:
		break