【Minecraft】塔を作る

城を作る続きで、今度は城郭に扉をつけて、城郭内に塔を建てましょう。

扉は城郭一辺のほぼ中央に鉄の扉(IRON_BLOCK)にて幅2☓高さ3とします。

塔は城郭の中央に位置するように調整し、幅7、高さ20とします。

城郭のコードに追加する形でこのようにしました。

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

import server
import sys



mc = minecraft.Minecraft()
mc.postToChat("Wall!")
playerPos = mc.player.getPos()
mc.player.setRotation(0)

width = 31
height = 6
org_x = playerPos.x + 5
org_y = playerPos.y
org_z = playerPos.z + 5

# X軸側の壁(手前)
for y in range(0, height):
	for x in range(1, width):
            mc.setBlock(
                org_x + x,
                org_y + y,
                org_z,
                block.STONE_BRICK)
for x in range(1, width, 2):
	mc.setBlock(
		org_x + x,
		org_y + height,
		org_z,
		block.STONE_BRICK)
for x in range(2, width, 2):
	mc.setBlock(
		org_x + x,
		org_y + height,
		org_z,
		block.TORCH)

# X軸側の壁(奥)
for y in range(0, height):
	for x in range(1, width):
            mc.setBlock(
                org_x + x,
                org_y + y,
                org_z + width,
                block.STONE_BRICK)
for x in range(1, width, 2):
	mc.setBlock(
		org_x + x,
		org_y + height,
		org_z + width,
		block.STONE_BRICK)
for x in range(2, width, 2):
	mc.setBlock(
		org_x + x,
		org_y + height,
		org_z + width,
		block.TORCH)

# Z軸側の壁(手前)
for y in range(0, height):
	for z in range(1, width):
            mc.setBlock(
                org_x,
                org_y + y,
                org_z + z,
                block.STONE_BRICK)
for z in range(1, width, 2):
	mc.setBlock(
		org_x,
		org_y + height,
		org_z + z,
		block.STONE_BRICK)
for z in range(2, width, 2):
	mc.setBlock(
		org_x,
		org_y + height,
		org_z + z,
		block.TORCH)

# Z軸側の壁(奥)
for y in range(0, height):
	for z in range(1, width):
            mc.setBlock(
                org_x + width,
                org_y + y,
                org_z + z,
                block.STONE_BRICK)
for z in range(1, width, 2):
	mc.setBlock(
		org_x + width,
		org_y + height,
		org_z + z,
		block.STONE_BRICK)
for z in range(2, width, 2):
	mc.setBlock(
		org_x + width,
		org_y + height,
		org_z + z,
		block.TORCH)

# 扉を作る
for y in range(0, height-2):
	mc.setBlock(
		org_x,
		org_y + y,
		org_z + int(width/2) - 1,
		block.IRON_BLOCK)
	mc.setBlock(
		org_x,
		org_y + y,
		org_z + int(width/2),
		block.IRON_BLOCK)
	mc.setBlock(
		org_x,
		org_y + y,
		org_z + int(width/2) + 1,
		block.IRON_BLOCK)


# 塔を建てる

TOWER_width = 7
TOWER_height = 20
TOWER_OFFEST_x = int((width-TOWER_width)/2)
TOWER_OFFEST_z = int((width-TOWER_width)/2)

# X軸側の塔(手前)
for y in range(0, TOWER_height):
	for x in range(1, TOWER_width):
            mc.setBlock(
                org_x + x + TOWER_OFFEST_x,
                org_y + y,
                org_z + TOWER_OFFEST_z,
                block.STONE_BRICK)

# X軸側の塔(奥)
for y in range(0, TOWER_height):
	for x in range(1, TOWER_width):
            mc.setBlock(
                org_x + x + TOWER_OFFEST_x,
                org_y + y,
                org_z + TOWER_width + TOWER_OFFEST_z,
                block.STONE_BRICK)

# Z軸側の塔(手前)
for y in range(0, TOWER_height):
	for z in range(1, TOWER_width):
            mc.setBlock(
                org_x + TOWER_OFFEST_x,
                org_y + y,
                org_z + z + TOWER_OFFEST_z,
                block.STONE_BRICK)

# Z軸側の塔(奥)
for y in range(0, TOWER_height):
	for z in range(1, TOWER_width):
            mc.setBlock(
                org_x + TOWER_width + TOWER_OFFEST_x,
                org_y + y,
                org_z + z + TOWER_OFFEST_x,
                block.STONE_BRICK)
mc.postToChat("Wall constructed!")

こんな感じになりますね。次回は、もう少し改良します。

Add a Comment

メールアドレスが公開されることはありません。