from mcpi_e.minecraft import Minecraft
import mcpi_e.block as block
mc = Minecraft.create()
# Function to build a house
def build_house(x, y, z):
# House dimensions
width = 7
height = 4
length = 7
# Build the floor
mc.setBlocks(x, y, z, x + width, y, z + length, block.WOOD.id)
# Build the walls
mc.setBlocks(x, y + 1, z, x + width, y + height, z, block.BRICK_BLOCK.id) # Front wall
mc.setBlocks(x, y + 1, z + length, x + width, y + height, z + length, block.BRICK_BLOCK.id) # Back wall
mc.setBlocks(x, y + 1, z, x, y + height, z + length, block.BRICK_BLOCK.id) # Left wall
mc.setBlocks(x + width, y + 1, z, x + width, y + height, z + length, block.BRICK_BLOCK.id) # Right wall
# Clear the inside
mc.setBlocks(x + 1, y + 1, z + 1, x + width - 1, y + height, z + length - 1, block.AIR.id)
# Build the ceiling
mc.setBlocks(x, y + height + 1, z, x + width, y + height + 1, z + length, block.WOOD.id)
# Make a door
mc.setBlock(x + width // 2, y + 1, z, block.DOOR_WOOD.id)
mc.setBlock(x + width // 2, y + 2, z, block.DOOR_WOOD.id)
# Make windows
mc.setBlocks(x + 1, y + 2, z, x + 2, y + 3, z, block.GLASS.id) # Front windows
mc.setBlocks(x + 1, y + 2, z + length, x + 2, y + 3, z + length, block.GLASS.id) # Back windows
mc.setBlocks(x, y + 2, z + 1, x, y + 3, z + 2, block.GLASS.id) # Left windows
mc.setBlocks(x + width, y + 2, z + 1, x + width, y + 3, z + 2, block.GLASS.id) # Right windows
# Get the player's position
pos = mc.player.getTilePos()
# Build the house
build_house(pos.x, pos.y, pos.z)