Pumpkin

Challenge

It’s nearly Halloween so we can use Minecraft to build something apart from buildings. How about a pumpkin?

As before, start up an instance of Pi Minecraft and a terminal window. Write a program to create a block of pumpkin coloured material, then remove blocks to “carve” it into a recognizable shape.

Example Solution


import mcpi.minecraft as minecraft
import mcpi.block as block

world = minecraft.Minecraft.create()

# material to use to make the pumpkin
orangeWool = block.Block(35,1)
greyWool = block.Block(35,8)

def clear_pumpkin():
	#Body of pumpkin
	world.setBlocks(-5,0,15,5,0,15, orangeWool)
	world.setBlocks(-8,1,15,8,1,15, orangeWool)
	world.setBlocks(-9,3,15,9,2,15, orangeWool)
	world.setBlocks(-10,7,15,10,4,15, orangeWool)
	world.setBlocks(-9,9,15,9,7,15, orangeWool)
	world.setBlocks(-8,10,15,8,10,15, orangeWool)
	world.setBlocks(-5,11,15,5,11,15, orangeWool)

	#Stalk
	world.setBlocks(-1,12,15,1,12,15, greyWool)
	world.setBlocks(0,13,15,2,13,15, greyWool)
	world.setBlocks(1,14,15,2,14,15, greyWool)


def make_pumpkin():
	#eyes
	world.setBlocks(-3,8,15,-2,7,15, block.AIR)
	world.setBlocks(2,8,15,3,7,15, block.AIR)

	#mouth
	world.setBlocks(-4,4,15,-4,3,15, block.AIR)
	world.setBlocks(-4,3,15,-1,3,15, block.AIR)
	world.setBlocks(-2,2,15,2,2,15, block.AIR)
	world.setBlocks(1,3,15,4,3,15, block.AIR)
	world.setBlocks(4,4,15,4,3,15, block.AIR)

clear_pumpkin()
make_pumpkin()