# 練習問題答え
- 正解のプログラム例は下のとおり
import mcpi.minecraft as minecraft
mc = minecraft.Minecraft.create()
sheep_colors = [
[8, 8, 8, 8, 8, 8, 8, 8],
[8, 0, 0, 0, 0, 0, 0, 8],
[8, 12, 12, 12, 12, 12, 12, 8],
[8, 15, 0, 12, 12, 0, 15, 8],
[8, 12, 12, 12, 12, 12, 12, 8],
[8, 0, 12, 6, 6, 12, 0, 8],
[8, 0, 12, 6, 6, 12, 0, 8],
[8, 8, 8, 8, 8, 8, 8, 8]
]
mooshroom_colors = [
[14, 14, 14, 8, 8, 7, 7, 14],
[14, 14, 14, 8, 8, 8, 14, 14],
[15, 15, 14, 8, 8, 14, 15, 15],
[15, 15, 14, 8, 14, 14, 15, 15],
[14, 14, 14, 14, 14, 14, 14, 14],
[14, 12, 0, 0, 0, 0, 12, 14],
[14, 0, 15, 7, 7 ,15, 0, 14],
[14, 0, 14, 7, 7, 14, 0, 14]
]
fox_colors = [
[8, 8, 0, 0, 0, 0, 8, 8],
[8, 7, 0, 0, 0, 0, 7, 8],
[12, 12, 12, 12, 12, 12, 12, 12],
[12, 12, 12, 12, 12, 12, 12, 12],
[12, 12, 12, 12, 12, 12, 12, 12],
[15, 0, 12, 12, 12, 12, 0, 15],
[12, 12, 8, 15, 15, 8, 12, 12],
[8, 8, 0, 0, 0, 0, 8, 8]
]
def draw(x, y, z, colors):
height = len(colors)
for i in range(height):
row = colors[i]
width = len(row)
for j in range(width):
mc.setBlock(x + j, y + 8 - i, z, 35, row[j])
x, y, z = mc.player.getPos()
draw(x, y, z, sheep_colors)
draw(x, y + 8, z, mooshroom_colors)
draw(x, y + 16, z, fox_colors)