Countdown to Christmas Makes Challenge 2017 – Day 18

A Christmas Present & Igloo

Built using Python 3.x
for the Raspberry Pi version of Minecraft

A Christmas Present & Igloo, built using 3-dimensional lists in Python 3.x for the Raspberry Pi version of Minecraft.


Christmas Present Python 3.x Code

from mcpi.minecraft import Minecraft
import time

mc = Minecraft.create()

# No Block = -1, White = 0, Orange = 1, Magenta = 2, Light Blue = 3,
# Yellow = 4, Lime = 5, Pink = 6, Grey = 7, Light Grey = 8,
# Cyan = 9, Purple = 10, Blue = 11, Brown = 12, Green = 13, Red = 14, Black = 15

present = [
	[
		[14, 14, 13, 14, 14],
		[14, 14, 13, 14, 14],
		[13, 13, 13, 13, 13],
		[14, 14, 13, 14, 14],
		[14, 14, 13, 14, 14]
	],
	[
		[14, 14, 13, 14, 14],
		[14, 14, 14, 14, 14],
		[13, 14, 14, 14, 13],
		[14, 14, 14, 14, 14],
		[14, 14, 13, 14, 14]
	],
	[
		[14, 14, 13, 14, 14],
		[14, 14, 14, 14, 14],
		[13, 14, 14, 14, 13],
		[14, 14, 14, 14, 14],
		[14, 14, 13, 14, 14]
	],
	[
		[14, 14, 13, 14, 14],
		[14, 14, 14, 14, 14],
		[13, 14, 14, 14, 13],
		[14, 14, 14, 14, 14],
		[14, 14, 13, 14, 14]
	],
	[
		[14, 14, 13, 14, 14],
		[14, 14, 13, 14, 14],
		[13, 13, 13, 13, 13],
		[14, 14, 13, 14, 14],
		[14, 14, 13, 14, 14]
	],
	[
		[-1, -1, -1, -1, -1],
		[-1, -1, -1, -1, -1],
		[-1, -1, 13, -1, -1],
		[-1, -1, -1, -1, -1],
		[-1, -1, -1, -1, -1]
	],
	[
		[-1, -1, -1, -1, -1],
		[-1, -1, -1, -1, -1],
		[-1, 13, -1, 13, -1],
		[-1, -1, -1, -1, -1],
		[-1, -1, -1, -1, -1]
	],
]


block = 35 # wool
x, y, z = mc.player.getPos()

y = 0
x = x - 8
z = z + -8

time.sleep(1)
py = 0
for a in present:
	pz = 0
	for b in a:
		px = 0
		for c in b:
			if c >= 0:
				mc.setBlock(x + px, y + py, z + pz, block, c)
				time.sleep(0.1)
			px = px + 1
		pz = pz + 1
	py = py + 1

Igloo Python 3.x Code

from mcpi.minecraft import Minecraft
import time

mc = Minecraft.create()

igloo = [
	[
		[-1, -1, -1, 80, 80, 80, -1, -1, -1],
		[-1, 80, 80, 78, 78, 78, 80, 80, -1],
		[80, 80, 78, 78, 78, 78, 78, 80, 80],
		[80, 78, 78, 78,  1, 78, 78, 78, 80],
		[80, 78, 78,  1, 10,  1, 78, 78, 80],
		[80, 78, 78, 78,  1, 78, 78, 78, 80],
		[80, 80, 78, 78, 78, 78, 78, 80, 80],
		[-1, 80, 80, 78, 78, 78, 80, 80, -1],
		[-1, -1, -1, 80, 78, 80, -1, -1, -1],
		[-1, -1, -1, 80, 78, 80, -1, -1, -1]
	],
	[
		[-1, -1, -1, 80, 79, 80, -1, -1, -1],
		[-1, -1, 80, -1, -1, -1, 80, -1, -1],
		[-1, 80, -1, -1, -1, -1, -1, 80, -1],
		[80, -1, -1, -1, -1, -1, -1, -1, 80],
		[79, -1, -1, -1, -1, -1, -1, -1, 79],
		[80, -1, -1, -1, -1, -1, -1, -1, 80],
		[-1, 80, -1, -1, -1, -1, -1, 80, -1],
		[-1, -1, 80, -1, -1, -1, 80, -1, -1],
		[-1, -1, -1, 80, -1, 80, -1, -1, -1],
		[-1, -1, -1, 80, -1, 80, -1, -1, -1]
	],
	[
		[-1, -1, -1, -1, -1, -1, -1, -1, -1],
		[-1, -1, -1, 80, 80, 80, -1, -1, -1],
		[-1, -1, 80, -1, -1, -1, 80, -1, -1],
		[-1, 80, -1, -1, -1, -1, -1, 80, -1],
		[-1, 80, -1, -1, -1, -1, -1, 80, -1],
		[-1, 80, -1, -1, -1, -1, -1, 80, -1],
		[-1, -1, 80, -1, -1, -1, 80, -1, -1],
		[-1, -1, -1, 80, 80, 80, -1, -1, -1],
		[-1, -1, -1, -1, 80, -1, -1, -1, -1],
		[-1, -1, -1, -1, 80, -1, -1, -1, -1]
	],
	[
		[-1, -1, -1, -1, -1, -1, -1, -1, -1],
		[-1, -1, -1, -1, -1, -1, -1, -1, -1],
		[-1, -1, -1, 80, 80, 80, -1, -1, -1],
		[-1, -1, 80, 80, 80, 80, 80, -1, -1],
		[-1, -1, 80, 80, 80, 80, 80, -1, -1],
		[-1, -1, 80, 80, 80, 80, 80, -1, -1],
		[-1, -1, -1, 80, 80, 80, -1, -1, -1],
		[-1, -1, -1, -1, -1, -1, -1, -1, -1],
		[-1, -1, -1, -1, -1, -1, -1, -1, -1],
		[-1, -1, -1, -1, -1, -1, -1, -1, -1]
	]
]

x, y, z = mc.player.getPos()

y = 0
x = x - 8
z = z + -8

py = 0
for a in igloo:
	pz = 0
	for b in a:
		px = 0
		for c in b:
			if c >= 0:
				mc.setBlock(x + px, y + py, z + pz, c)
				time.sleep(0.1)
			px = px + 1
		pz = pz + 1
	py = py + 1

Leave a Reply