コード例 #1
0
 def test_rotate_right(self):
     v = Vec3(2, -3, 8)
     v.rotateRight()
     expect_vec = Vec3(-8, -3, 2)
     assert v == expect_vec
コード例 #2
0
ファイル: game.py プロジェクト: dansmith9/sequence-game
from mcpi.minecraft import Minecraft
from mcpi import block
from mcpi.vec3 import Vec3
import time
from datetime import datetime
import random
from math import trunc
import picamera
import unicornhat as UH
from threading import Thread

mc = Minecraft.create()

puzRoomStart = Vec3(0, 0, 0)

puzRoomLength = 12
puzRoomWidth = 12
puzRoomHeight = 8

puzRoomFloorStart = Vec3(2, 0, 2)
puzRoomFloorEnd = Vec3(puzRoomLength - 2, 1, puzRoomWidth - 2)

blue = Vec3(3, 2, 4)
yellow = Vec3(5, 2, 4)
red = Vec3(7, 2, 4)
green = Vec3(9, 2, 4)
startPos = Vec3(6, 2, 10)

difficulty = 1
sequence = []
blocklist = [blue, yellow, red, green]
コード例 #3
0
from mcpi.block import *
from mcpi.minecraft import Minecraft
from mcpi.vec3 import Vec3

mc = Minecraft.create()
my_id = mc.getPlayerEntityId("_Egor_S_")

center = mc.entity.getTilePos(my_id) - Vec3(0, 1, 0)
height = 6

mc.setBlock(center, 138)
for y in range(1, height + 1):
    mc.setBlocks(center + Vec3(-y, -y, -y), center + Vec3(y, -y, y),
                 IRON_BLOCK)
コード例 #4
0
    def _create_walls(self):
        builds = []
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(0, self.base_level + 1, 0),
                          block.STONE_BRICK,
                          Building.SE_CORNER_POS + Vec3(0, -1, -1),
                          description="moat wall"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-1, self.base_level + 1, -2),
                          block.STONE_BRICK,
                          Building.SE_CORNER_POS + Vec3(-1, -1, -3),
                          description="moat wall"))

        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-2, self.base_level + 1, -4),
                          block.STONE_BRICK,
                          Building.SE_CORNER_POS + Vec3(-2, -1, -4),
                          description="moat wall"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-3, self.base_level + 1, -5),
                          block.STONE_BRICK,
                          Building.SE_CORNER_POS + Vec3(-3, -1, -5),
                          description="moat wall"))

        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-4, self.base_level + 1, -6),
                          block.STONE_BRICK,
                          Building.SE_CORNER_POS + Vec3(-5, -1, -6),
                          description="moat wall"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-6, self.base_level + 1, -7),
                          block.STONE_BRICK,
                          Building.SE_CORNER_POS + Vec3(-7, -1, -7),
                          description="moat wall"))

        self._add_section("Wall turret moat - walls", builds)
コード例 #5
0
    def _create_structure(self):
        super(Pantry, self)._create_structure()
        builds = []
        builds.append(
            SubBuilding(OpenDoorway(Building.NORTH),
                        Building.SE_CORNER_POS + Vec3(-3, 0, 0)))
        builds.append(
            SubBuilding(OpenDoorway(Building.EAST),
                        Pantry.WALLS_CORNER_POS['South East'] +
                        Vec3(0, 0, -2)))

        self._add_section("Pantry Doorways", builds)

        ############################################################################
        # add chests
        # on south wall
        builds.append(
            Chest(Pantry.WALLS_CORNER_POS['South East'] + Vec3(-1, 0, -1),
                  block.CHEST.withData(Chest.EAST),
                  Pantry.WALLS_CORNER_POS['South East'] + Vec3(-2, 1, -1),
                  description="South wall chests"))
        builds.append(
            Chest(Pantry.WALLS_CORNER_POS['South West'] + Vec3(1, 0, -1),
                  block.CHEST.withData(Chest.EAST),
                  Pantry.WALLS_CORNER_POS['South West'] + Vec3(2, 1, -1),
                  description="South wall chests"))

        # on north wall
        builds.append(
            Chest(Pantry.WALLS_CORNER_POS['North East'] + Vec3(-2, 0, 1),
                  block.CHEST.withData(Chest.EAST),
                  Pantry.WALLS_CORNER_POS['North East'] + Vec3(-3, 1, 1),
                  description="South wall chests"))
        builds.append(
            Chest(Pantry.WALLS_CORNER_POS['North West'] + Vec3(1, 0, 1),
                  block.CHEST.withData(Chest.EAST),
                  Pantry.WALLS_CORNER_POS['North West'] + Vec3(2, 1, 1),
                  description="South wall chests"))

        # on west wall
        builds.append(
            Chest(Pantry.WALLS_CORNER_POS['South West'] + Vec3(1, 0, -3),
                  block.CHEST.withData(Chest.EAST),
                  Pantry.WALLS_CORNER_POS['South West'] + Vec3(1, 1, -4),
                  description="South wall chests"))

        # on east wall
        builds.append(
            Chest(Pantry.WALLS_CORNER_POS['North East'] + Vec3(-1, 0, 2),
                  block.CHEST.withData(Chest.EAST),
                  Pantry.WALLS_CORNER_POS['North East'] + Vec3(-1, 1, 3),
                  description="South wall chests"))

        self._add_section("Pantry Chests", builds)

        ############################################################################
        #torches,
        # south wall torches either side of arched doorway
        builds.append(
            Torch(Pantry.WALLS_CORNER_POS['South East'] + Vec3(-2, 2, -1),
                  block.TORCH.withData(Torch.NORTH)))
        builds.append(
            Torch(Pantry.WALLS_CORNER_POS['South West'] + Vec3(2, 2, -1),
                  block.TORCH.withData(Torch.NORTH)))
        # torch on west wall sw corner
        builds.append(
            Torch(Pantry.WALLS_CORNER_POS['South West'] + Vec3(1, 2, -2),
                  block.TORCH.withData(Torch.EAST)))

        # torches in north east corner on north & east walls
        builds.append(
            Torch(Pantry.WALLS_CORNER_POS['North East'] + Vec3(-2, 2, 1),
                  block.TORCH.withData(Torch.SOUTH)))
        # this is only torch on west wall, move closer to center
        builds.append(
            Torch(Pantry.WALLS_CORNER_POS['North East'] + Vec3(-1, 2, 3),
                  block.TORCH.withData(Torch.WEST)))

        # torches in north west corner on north & west walls.
        builds.append(
            Torch(Pantry.WALLS_CORNER_POS['North West'] + Vec3(2, 2, 1),
                  block.TORCH.withData(Torch.SOUTH)))
        builds.append(
            Torch(Pantry.WALLS_CORNER_POS['North West'] + Vec3(1, 2, 2),
                  block.TORCH.withData(Torch.EAST)))

        self._add_section("Pantry Torches", builds)
コード例 #6
0
from mcpi.minecraft import Minecraft
from mcpi.vec3 import Vec3
import time

#请自行修改服务器的ip地址
mc=Minecraft.create("192.168.2.207",4711)

poss=[]

#4个玩家的初始基地位置
poss.append(Vec3(48,0,20))
poss.append(Vec3(105,-1,47))
poss.append(Vec3(107,6,121))
poss.append(Vec3(63,8,123))

#先巡视一下所有基地
for pos in poss:
    mc.player.setTilePos(pos)
    time.sleep(2)

stayed_time=0

while True:
    stayed_time+=1
    print("xkn stay_time"+str(stayed_time))
    time.sleep(2)
    #建造带火把的通天柱子为每个玩家标定位置,玩家编号为柱子中的连续石块的数字,为防止被破坏,每3秒恢复一次
    for idx,pos in enumerate(poss):
        for y in range(50):
            mc.setBlock(pos.x,pos.y+y,pos.z,1 if y%(idx+1) else 2)
            mc.setBlock(pos.x+1,pos.y+y,pos.z,50)
コード例 #7
0
            maze_Conn.setRange(maze_pos, maze_end)
            maze_Conn.connect((mazeXSize - 2) / 3)
        #eof while > topMazeWidth

    #eof _buildMazes


#eof TempleBuilder

if __name__ == "__main__":
    """user variables"""
    # your world spawn location
    spawnX = 200
    spawnY = 63
    spawnZ = 200
    spawn = Vec3(spawnX, spawnY, spawnZ)

    # temple center coordinates
    # in the middle of a jungle
    x0 = 0
    z0 = 0
    y0 = 68
    centre = Vec3(x0, y0, z0)

    levels = 10  # limited by the 490 loot items

    temple = TempleBuilder(levels, centre, spawn)
    temple.build()
#eof main
コード例 #8
0
class Well(Building):

    WELL_OUTER_SPAN = (Building.SE_CORNER_POS,
                       Building.SE_CORNER_POS + Vec3(-5, 0, -5))
    WELL_CORE_POS = (WELL_OUTER_SPAN[0] + Vec3(-1, 0, -1),
                     WELL_OUTER_SPAN[0] + Vec3(-4, 0, -4),
                     WELL_OUTER_SPAN[0] + Vec3(-4, 0, -1),
                     WELL_OUTER_SPAN[0] + Vec3(-1, 0, -4))
    WELL_INNER_SPAN = (WELL_OUTER_SPAN[0] + Vec3(-2, 0, -2),
                       WELL_OUTER_SPAN[0] + Vec3(-3, 0, -3))

    WIDTH = 6

    def __init__(self, *args, **kwargs):
        super(Well, self).__init__(width=Well.WIDTH, *args, **kwargs)

        # level -3, base
        base = []
        base.append(
            BuildingBlock(Well.WELL_CORE_POS[0],
                          block.COBBLESTONE,
                          Well.WELL_CORE_POS[1],
                          description="Well base"))
        self.add_layer(BuildingLayer(base, -3))

        # level -2, water
        water = []
        water.extend(base)
        water.append(
            BuildingBlock(Well.WELL_INNER_SPAN[0],
                          block.WATER,
                          Well.WELL_INNER_SPAN[1],
                          description="Well water"))

        self.add_layer(BuildingLayer(water, -2))

        layer_blocks = []
        # level -1, ground
        layer_blocks.append(
            BuildingBlock(Well.WELL_OUTER_SPAN[0],
                          block.GRAVEL,
                          Well.WELL_OUTER_SPAN[1],
                          description="Well ground surround"))
        layer_blocks.extend(water)

        self.add_layer(BuildingLayer(layer_blocks, -1))
        del layer_blocks[:]

        # level 0, walls
        layer_blocks.extend(base)
        layer_blocks.append(
            BuildingBlock(Well.WELL_INNER_SPAN[0],
                          block.AIR,
                          Well.WELL_INNER_SPAN[1],
                          description="Well clear inner"))

        self.add_layer(BuildingLayer(layer_blocks, 0))
        del layer_blocks[:]

        # levels 1 & 2, supports
        supports = []
        for pos in Well.WELL_CORE_POS:
            supports.append(
                BuildingBlock(pos, block.FENCE, description="Well support"))

        self.add_layer(BuildingLayer(supports, 1))
        self.add_layer(BuildingLayer(supports, 2))

        # level 3 roof
        base[0].description = "Well roof"
        self.add_layer(BuildingLayer(base, 3))

        self._set_orientation()
コード例 #9
0
ファイル: aleks_bunkermatic.py プロジェクト: Sasho1256/mcpipy
    #eof build


#eof BunkerBuilder

if __name__ == "__main__":
    #spawn
    x0 = 200
    y0 = 65
    z0 = 200

    # bunker top MC coordinates
    x = 303
    y = 115
    z = 88
    bottom = 45  # MC y layer coordinate
    material_id = 49
    light_id = 76  # block.REDSTONE_TORCH_ON.id

    x1 = x - x0
    y1 = y - y0
    z1 = z - z0
    long_tun = 4
    long_arc_ch = 7
    long_ch = 30

    vect = Vec3(x1, y1, z1)
    builder = BunkerBuilder(vect, y0, long_tun, long_arc_ch, long_ch, bottom,
                            material_id, light_id)
    builder.build()
#eof main
コード例 #10
0
 def test_subtraction(self):
     a = Vec3(10, -3, 4)
     b = Vec3(5, 3, 5)
     assert (a - a) == Vec3(0, 0, 0)
     assert (a + (-a)) == Vec3(0, 0, 0)
     assert (a - b) == Vec3(5, -6, -1)
コード例 #11
0
 def test_multiplication(self):
     a = Vec3(2, -3, 8)
     assert (a + a) == (a * 2)
     k = 4
     a *= k
     assert a == Vec3(2 * k, -3 * k, 8 * k)
コード例 #12
0
 def test_negation(self):
     v1 = Vec3(2, -3, 8)
     v_inverse = -v1
     assert v1.x == -v_inverse.x
     assert v1.y == -v_inverse.y
     assert v1.z == -v_inverse.z
コード例 #13
0
 def test_cloning(self):
     v = Vec3(2, -3, 8)
     v_clone = v.clone()
     assert v == v_clone
     v.x += 1
     assert v != v_clone
コード例 #14
0
 def test_iteration(self):
     coords = [1, 9, 6]
     v = Vec3(coords[0], coords[1], coords[2])
     for index, pos in enumerate(v):
         assert pos == coords[index]
コード例 #15
0
    #print("Printing ...")
    #data_file = MANSION_DATA
    #data = CoordinateUtils.read_data_from_file(data_file)
    #data = CoordinateUtils.shift_coordinates(data, v)
    #scanner.print_3d(data)

    ##### initial coordinates
    #Xo = -166
    #Yo= 0
    #Zo = 34

    ###### scan mansion
    #print("Scanning ...")
    #v1 = Vec3(Xo, Yo, Zo)
    #v2 = Vec3(-129, 24, 67)
    #data_file = MANSION_DATA
    #data = scanner.scan_3d(v1, v2)
    #data = CoordinateUtils.calculate_relative_coordinates(data)
    #CoordinateUtils.save_data_to_file(data, data_file)

    #### build mansion
    x = 40
    y = -9
    z = 0
    v = Vec3(x, y, z)
    print("Printing ...")
    data_file = MANSION_DATA
    data = CoordinateUtils.read_data_from_file(data_file)
    data = CoordinateUtils.shift_coordinates(data, v)
    scanner.print_3d(data)
コード例 #16
0
def drawVerticalOutline(mc, x0, y0, x1, y1, z, blockType, blockData=0):
    mc.setBlocks(x0, y0, z, x0, y1, z, blockType, blockData)
    mc.setBlocks(x0, y1, z, x1, y1, z, blockType, blockData)
    mc.setBlocks(x1, y1, z, x1, y0, z, blockType, blockData)
    mc.setBlocks(x1, y0, z, x0, y0, z, blockType, blockData)


if __name__ == "__main__":

    mc = Minecraft.create()
    mc.postToChat("Hello, 麥塊貪食蛇, CodingAPE猿創力程式設計學校")
    pos = mc.player.getTilePos()

    while True:
        #constants
        screenBottomLeft = Vec3(pos.x - 10, pos.y + 4, pos.z + 25)
        screenTopRight = Vec3(pos.x + 10, pos.y + 24, pos.z + 25)
        playingBottomLeft = Vec3(pos.x - 10, pos.y + 4, pos.z + 24)
        playingTopRight = Vec3(pos.x + 10, pos.y + 24, pos.z + 24)
        snakeStart = Vec3(pos.x, pos.y + 5, pos.z + 24)

        #Build game board
        # clear a suitably large area
        mc.setBlocks(pos.x - 10, pos.y, pos.z - 5, pos.x + 10, pos.y + 25,
                     pos.z + 26, 0)
        # create playing board
        mc.setBlocks(screenBottomLeft.x, screenBottomLeft.y,
                     screenBottomLeft.z, screenTopRight.x, screenTopRight.y,
                     screenTopRight.z, 1)
        drawVerticalOutline(mc, playingBottomLeft.x, playingBottomLeft.y,
                            playingTopRight.x, playingTopRight.y,
コード例 #17
0
    for i in range(0, 5):
        find_player_position()
        time.sleep(1)

    ## starting coordiantes
    Xo = 119
    Yo = -5
    Zo = -218

    ### build house
    #house_builder = House()
    #house_builder.build_house(Vec3(Xo, Yo, Zo))

    #### scan ships
    print("Scanning ...")
    v1 = Vec3(Xo, Yo, Zo)
    v2 = Vec3(Xo + 26, Yo + 13, Zo + 12)
    data_file = HOUSE_DATA
    data = scanner.scan_3d(v1, v2)
    data = CoordinateUtils.calculate_relative_coordinates(data)
    CoordinateUtils.save_data_to_file(data, data_file)

    #### build ships
    v = Vec3(74, -5, -272)
    print("Printing ...")
    data_file = HOUSE_DATA
    data = CoordinateUtils.read_data_from_file(data_file)
    data = CoordinateUtils.shift_coordinates(data, v)
    scanner.print_3d(data)
#
コード例 #18
0
import random
import time

from mcpi.minecraft import Minecraft
from mcpi.vec3 import Vec3

mc = Minecraft.create()
my_id = mc.getPlayerEntityId('_Egor_S_')

rand_pos = Vec3(random.randint(-30, 30), 0, random.randint(-30, 30)) + mc.entity.getPos(my_id)
while True:
    shift = rand_pos - mc.entity.getPos(my_id)
    d = shift.length()
    if d < 1:
        mc.postToChat("You found it! Good job.")
        break
    mc.postToChat("Distance to target: {:2f}".format(d))
    time.sleep(1)
コード例 #19
0
ファイル: enchanting.py プロジェクト: petemulholland/learning
    def _create_structure(self):
        super(EnchantingRoom, self)._create_structure()
        builds = []
        builds.append(
            SubBuilding(OpenDoorway(Building.NORTH),
                        Building.SE_CORNER_POS + Vec3(-1, 0, 0)))
        builds.append(
            SubBuilding(
                OpenDoorway(Building.EAST),
                EnchantingRoom.WALLS_CORNER_POS['South East'] +
                Vec3(0, 0, -2)))

        #builds.append(BuildingBlock(EnchantingRoom.WALLS_CORNER_POS['North East'] + Vec3(-2,1,0),
        #							block.GLASS_PANE,
        #							EnchantingRoom.WALLS_CORNER_POS['North East'] + Vec3(-5,1,0),
        #							description="Window"))
        self._add_section("Enchanting Room Doorways", builds)

        ############################################################################
        # Bookshelves & enchanting table
        builds.append(
            BuildingBlock(
                EnchantingRoom.WALLS_CORNER_POS['South West'] + Vec3(1, 0, -1),
                BOOK_SHELF,
                EnchantingRoom.WALLS_CORNER_POS['South West'] + Vec3(4, 1, -1),
                description="bookshelves"))
        builds.append(
            BuildingBlock(
                EnchantingRoom.WALLS_CORNER_POS['South West'] + Vec3(1, 0, -1),
                BOOK_SHELF,
                EnchantingRoom.WALLS_CORNER_POS['South West'] + Vec3(1, 1, -5),
                description="bookshelves"))
        builds.append(
            BuildingBlock(EnchantingRoom.WALLS_CORNER_POS['South West'] +
                          Vec3(3, 0, -3),
                          ENCHANTING_TABLE,
                          description="Enchanting table"))

        builds.append(
            Chest(
                EnchantingRoom.WALLS_CORNER_POS['North East'] + Vec3(-1, 0, 2),
                block.CHEST.withData(Chest.EAST),
                EnchantingRoom.WALLS_CORNER_POS['North East'] + Vec3(-1, 1, 3),
                description="South wall chests"))
        builds.append(
            Chest(
                EnchantingRoom.WALLS_CORNER_POS['North East'] + Vec3(-3, 0, 1),
                block.CHEST.withData(Chest.EAST),
                EnchantingRoom.WALLS_CORNER_POS['North East'] + Vec3(-4, 0, 1),
                description="South wall chests"))

        builds.append(
            BuildingBlock(EnchantingRoom.WALLS_CORNER_POS['North East'] +
                          Vec3(-2, 0, 1),
                          block.CRAFTING_TABLE,
                          description="crafting table"))

        self._add_section("Enchanting Room Fittings", builds)
        ############################################################################
        #torches,
        # south wall torches either side of arched doorway
        builds.append(
            Torch(
                EnchantingRoom.WALLS_CORNER_POS['South East'] +
                Vec3(-3, 2, -1), block.TORCH.withData(Torch.NORTH)))
        builds.append(
            Torch(
                EnchantingRoom.WALLS_CORNER_POS['South West'] + Vec3(2, 2, -1),
                block.TORCH.withData(Torch.NORTH)))
        # torch on west wall sw corner
        builds.append(
            Torch(
                EnchantingRoom.WALLS_CORNER_POS['South West'] + Vec3(1, 2, -2),
                block.TORCH.withData(Torch.EAST)))

        # torches in north east corner on north & east walls
        builds.append(
            Torch(
                EnchantingRoom.WALLS_CORNER_POS['North East'] + Vec3(-2, 2, 1),
                block.TORCH.withData(Torch.SOUTH)))
        # this is only torch on west wall, move closer to center
        builds.append(
            Torch(
                EnchantingRoom.WALLS_CORNER_POS['North East'] + Vec3(-1, 2, 3),
                block.TORCH.withData(Torch.WEST)))

        # torches in north west corner on north & west walls.
        builds.append(
            Torch(
                EnchantingRoom.WALLS_CORNER_POS['North West'] + Vec3(2, 2, 1),
                block.TORCH.withData(Torch.SOUTH)))
        builds.append(
            Torch(
                EnchantingRoom.WALLS_CORNER_POS['North West'] + Vec3(1, 2, 2),
                block.TORCH.withData(Torch.EAST)))

        self._add_section("Enchanting Room Torches", builds)
コード例 #20
0
def round_vec3(vec3):
    return Vec3(int(vec3.x), int(vec3.y), int(vec3.z))
コード例 #21
0
    def _create_water(self):
        builds = []
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-1, self.moat_bottom, 0),
                          block.AIR,
                          Building.SE_CORNER_POS + Vec3(-3, -1, -1),
                          description="moat - clear space down"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-2, self.moat_bottom, -2),
                          block.AIR,
                          Building.SE_CORNER_POS + Vec3(-4, -1, -3),
                          description="moat - clear space down"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-3, self.moat_bottom, -4),
                          block.AIR,
                          Building.SE_CORNER_POS + Vec3(-3, -1, -4),
                          description="moat - clear space down"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-4, self.moat_bottom, -3),
                          block.AIR,
                          Building.SE_CORNER_POS + Vec3(-5, -1, -5),
                          description="moat - clear space down"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-6, self.moat_bottom, -4),
                          block.AIR,
                          Building.SE_CORNER_POS + Vec3(-7, -1, -6),
                          description="moat - clear space down"))

        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-1, self.moat_bottom, 0),
                          block.WATER,
                          Building.SE_CORNER_POS + Vec3(-3, WATER_HEIGHT, -1),
                          description="moat water"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-2, self.moat_bottom, -2),
                          block.WATER,
                          Building.SE_CORNER_POS + Vec3(-4, WATER_HEIGHT, -3),
                          description="moat water"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-3, self.moat_bottom, -4),
                          block.WATER,
                          Building.SE_CORNER_POS + Vec3(-3, WATER_HEIGHT, -4),
                          description="moat water"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-4, self.moat_bottom, -3),
                          block.WATER,
                          Building.SE_CORNER_POS + Vec3(-5, WATER_HEIGHT, -5),
                          description="moat water"))
        builds.append(
            BuildingBlock(Building.SE_CORNER_POS +
                          Vec3(-6, self.moat_bottom, -4),
                          block.WATER,
                          Building.SE_CORNER_POS + Vec3(-7, WATER_HEIGHT, -6),
                          description="moat water"))
        self._add_section("Wall turret moat - water", builds)
コード例 #22
0
import time

import mcpi.minecraft as minecraft
from mcpi import block
from mcpi.vec3 import Vec3

from base.rooms.dining_hall import DiningHall
from building import Building
from mcpi.vec3 import Vec3

mc = minecraft.Minecraft.create()
pl = mc.player
cm = mc.camera

#build_pos = Vec3(0,0,-1)
build_pos = Vec3(0,0,0)

def debug_dining_hall():
	global mc
	ps = mc.player.getTilePos()

	build = DiningHall(Building.NORTH)
	build.build_to_left(mc, ps + Vec3(-1,0,-1))
	
def debug_building(type):
	global mc, build_pos
	ps = mc.player.getTilePos()
	ps += build_pos

	build = type(Building.NORTH)
	build.build_to_left(mc, ps + Vec3(build._width / 2,0,-2))
コード例 #23
0
    p2 = mc.player.getPos()  # the current player position
    v = p2 - p  # the vector from previous to current
    mag_v = np.sqrt(v.x * v.x + v.y * v.y +
                    v.z * v.z)  # the distance moved since last position fix

    if mag_v > 0.5:  # only if the player has moved since last position fix

        for ad in range(1, 7):
            ahead_distance = float(ad)
            v.x *= ahead_distance / mag_v  # (v.x, v.y, v.z) is the velocity vector
            v.y *= ahead_distance / mag_v  #    ...it points in the direction the player is moving
            v.z *= ahead_distance / mag_v  #    ...and so is the guide for tunnel-building direction

            xzHeading = -np.arctan2(v.x,
                                    v.z)  # azimuth heading in the xz plane
            cc = p2 + Vec3(v.x, v.y, v.z)  # 'circle center' = cc

            mc.setBlock(cc.x, cc.y, cc.z, air)
            for r in range(2, maxRadius + 1):
                fr = float(r)
                for thetaIndex in range(int(
                        6.4 * fr)):  # ring index: going around a circle
                    theta = float(
                        thetaIndex
                    ) * 2. * np.pi / 64.  # get an angle from this (radians)
                    dy, dx = fr * np.sin(theta), fr * np.cos(
                        theta)  # two coordinates of circle
                    dxx, dxz = np.cos(xzHeading) * dx, np.sin(
                        xzHeading) * dx  # xz-plane coordinates
                    mc.setBlock(cc.x + dxx, cc.y + dy, cc.z + dxz,
                                air)  # set a block in the ring
コード例 #24
0
def debug_dining_hall():
	global mc
	ps = mc.player.getTilePos()

	build = DiningHall(Building.NORTH)
	build.build_to_left(mc, ps + Vec3(-1,0,-1))
コード例 #25
0
class Library(Building):
    """description of class"""
    WALLS_CORNER_POS = {
        'South East': Building.SE_CORNER_POS + Vec3(0, 0, -1),
        'South West': Building.SE_CORNER_POS + Vec3(-8, 0, -1),
        'North West': Building.SE_CORNER_POS + Vec3(-8, 0, -6),
        'North East': Building.SE_CORNER_POS + Vec3(0, 0, -6)
    }

    NORTH_WIN_SPANS = {
        'North West': (WALLS_CORNER_POS['North East'] + Vec3(-5, 0, 0),
                       WALLS_CORNER_POS['North East'] + Vec3(-6, 0, 0)),
        'North East': (WALLS_CORNER_POS['North East'] + Vec3(-2, 0, 0),
                       WALLS_CORNER_POS['North East'] + Vec3(-3, 0, 0))
    }

    OTHER_WIN_SPANS = {
        'West': (WALLS_CORNER_POS['South West'] + Vec3(0, 0, -2),
                 WALLS_CORNER_POS['South West'] + Vec3(0, 0, -3)),
        'East': (WALLS_CORNER_POS['South East'] + Vec3(0, 0, -2),
                 WALLS_CORNER_POS['South East'] + Vec3(0, 0, -3)),
        'South': (WALLS_CORNER_POS['South East'] + Vec3(-4, 0, 0),
                  WALLS_CORNER_POS['South East'] + Vec3(-6, 0, 0))
    }

    DOOR_POS = WALLS_CORNER_POS['South East'] + Vec3(-1, 0, 0)

    WIDTH = 9

    def __init__(self, *args, **kwargs):
        super(Library, self).__init__(width=Library.WIDTH, *args, **kwargs)

        layer_blocks = []
        ########################################################################
        # level 1
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['South West'],
                          block.COBBLESTONE,
                          Library.WALLS_CORNER_POS['North East'],
                          description="Floor"))

        layer_blocks.append(
            Stair(Library.DOOR_POS + Vec3(0, 0, 1),
                  block.STAIRS_COBBLESTONE.withData(Stair.NORTH),
                  description="Front door step"))

        self.add_layer(BuildingLayer(layer_blocks, 0))
        del layer_blocks[:]

        ########################################################################
        # level 2
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['South West'],
                          block.COBBLESTONE,
                          Library.WALLS_CORNER_POS['North West'],
                          description="West wall"))
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['North West'],
                          block.COBBLESTONE,
                          Library.WALLS_CORNER_POS['North East'],
                          description="North wall"))
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['North East'],
                          block.COBBLESTONE,
                          Library.WALLS_CORNER_POS['South East'],
                          description="East wall"))
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['South East'],
                          block.COBBLESTONE,
                          Library.WALLS_CORNER_POS['South West'],
                          description="South wall"))
        # Clear door space
        layer_blocks.append(
            BuildingBlock(Library.DOOR_POS,
                          block.AIR,
                          description="Clear door"))
        # seats corner
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['North West'] +
                          Vec3(1, 0, 1),
                          block.WOOD_PLANKS,
                          description="seat corner"))
        # seats
        layer_blocks.append(
            Stair(Library.WALLS_CORNER_POS['North West'] + Vec3(1, 0, 2),
                  block.STAIRS_WOOD.withData(Stair.WEST),
                  description="west seat"))
        layer_blocks.append(
            Stair(Library.WALLS_CORNER_POS['North West'] + Vec3(2, 0, 1),
                  block.STAIRS_WOOD.withData(Stair.NORTH),
                  Library.WALLS_CORNER_POS['North West'] + Vec3(5, 0, 1),
                  description="north seats"))
        # table bases
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['South West'] +
                          Vec3(2, 0, -3),
                          block.FENCE,
                          description="table base"))
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['South West'] +
                          Vec3(4, 0, -3),
                          block.FENCE,
                          description="table base"))

        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['South West'] +
                          Vec3(1, 0, -1),
                          block.CRAFTING_TABLE,
                          description="crafting table"))

        self.add_layer(BuildingLayer(layer_blocks, 1))
        del layer_blocks[:]

        ########################################################################
        # Common sets of blocks
        corners = []
        for key, pos in Library.WALLS_CORNER_POS.items():
            corners.append(
                BuildingBlock(pos,
                              block.COBBLESTONE,
                              description=key + " corner"))
        # north windows are only used on 1 layer,
        # east, south & west are used on 2 levels
        other_windows = []
        for key, span in Library.OTHER_WIN_SPANS.items():
            other_windows.append(
                BuildingBlock(span[0],
                              block.GLASS_PANE,
                              span[1],
                              description=key + " window"))

        # these walls are used on 3 levels
        walls = []
        walls.append(
            BuildingBlock(
                Library.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -1),
                block.WOOD_PLANKS,
                Library.WALLS_CORNER_POS['North West'] + Vec3(0, 0, 1),
                description="West wall"))
        walls.append(
            BuildingBlock(
                Library.WALLS_CORNER_POS['North West'] + Vec3(1, 0, 0),
                block.WOOD_PLANKS,
                Library.WALLS_CORNER_POS['North East'] + Vec3(-1, 0, 0),
                description="North wall"))
        walls.append(
            BuildingBlock(
                Library.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 1),
                block.WOOD_PLANKS,
                Library.WALLS_CORNER_POS['South East'] + Vec3(0, 0, -1),
                description="East wall"))
        walls.append(
            BuildingBlock(
                Library.WALLS_CORNER_POS['South East'] + Vec3(-1, 0, 0),
                block.WOOD_PLANKS,
                Library.WALLS_CORNER_POS['South West'] + Vec3(1, 0, 0),
                description="South wall"))

        ########################################################################
        # level 3
        # corners & walls
        layer_blocks.extend(corners)
        layer_blocks.extend(walls)

        # north windows
        for key, span in Library.NORTH_WIN_SPANS.items():
            layer_blocks.append(
                BuildingBlock(span[0],
                              block.GLASS_PANE,
                              span[1],
                              description=key + " window"))
        # other windows
        layer_blocks.extend(other_windows)

        # Clear door space
        layer_blocks.append(
            BuildingBlock(Library.DOOR_POS,
                          block.AIR,
                          description="clear door"))

        # table bases
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['South West'] +
                          Vec3(2, 0, -3),
                          TABLE_TOP,
                          description="table top"))
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['South West'] +
                          Vec3(4, 0, -3),
                          TABLE_TOP,
                          description="table top"))

        self.add_layer(BuildingLayer(layer_blocks, 2))
        del layer_blocks[:]

        ########################################################################
        # level 4
        # corners & walls
        layer_blocks.extend(corners)
        layer_blocks.extend(walls)

        # books
        layer_blocks.append(
            BuildingBlock(
                Library.WALLS_CORNER_POS['North West'] + Vec3(1, 0, 1),
                block.BOOKSHELF,
                Library.WALLS_CORNER_POS['North East'] + Vec3(-1, 0, 1),
                description="Book shelves"))

        # other windows
        layer_blocks.extend(other_windows)

        self.add_layer(BuildingLayer(layer_blocks, 3))
        del layer_blocks[:]

        ########################################################################
        # level 5
        # corners & walls
        layer_blocks.extend(corners)
        layer_blocks.extend(walls)

        layer_blocks.append(
            BuildingBlock(
                Library.WALLS_CORNER_POS['North West'] + Vec3(0, 0, 1),
                block.WOOD_PLANKS,
                Library.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 1),
                description="North rafters"))
        layer_blocks.append(
            BuildingBlock(
                Library.WALLS_CORNER_POS['South East'] + Vec3(0, 0, -1),
                block.WOOD_PLANKS,
                Library.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -1),
                description="South rafters"))

        self.add_layer(BuildingLayer(layer_blocks, 4))
        del layer_blocks[:]

        ########################################################################
        # level 6
        layer_blocks.append(
            BuildingBlock(Library.WALLS_CORNER_POS['South West'],
                          block.COBBLESTONE,
                          Library.WALLS_CORNER_POS['North East'],
                          description="Ceiling"))
        # north and south roof eaves
        layer_blocks.append(
            Stair(Library.WALLS_CORNER_POS['North West'] + Vec3(0, 0, -1),
                  block.STAIRS_WOOD.withData(Stair.SOUTH),
                  Library.WALLS_CORNER_POS['North East'] + Vec3(0, 0, -1),
                  description="North roof eaves"))
        layer_blocks.append(
            Stair(Library.WALLS_CORNER_POS['South East'] + Vec3(0, 0, 1),
                  block.STAIRS_WOOD.withData(Stair.NORTH),
                  Library.WALLS_CORNER_POS['South West'] + Vec3(0, 0, 1),
                  description="South roof eaves"))

        self.add_layer(BuildingLayer(layer_blocks, 5))
        del layer_blocks[:]

        ########################################################################
        # level 7
        layer_blocks.append(
            BuildingBlock(
                Library.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -1),
                block.COBBLESTONE,
                Library.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 1),
                description="Ceiling"))
        # north and south roof eaves
        layer_blocks.append(
            Stair(Library.WALLS_CORNER_POS['North West'],
                  block.STAIRS_WOOD.withData(Stair.SOUTH),
                  Library.WALLS_CORNER_POS['North East'],
                  description="North roof eaves"))
        layer_blocks.append(
            Stair(Library.WALLS_CORNER_POS['South East'],
                  block.STAIRS_WOOD.withData(Stair.NORTH),
                  Library.WALLS_CORNER_POS['South West'],
                  description="South roof eaves"))

        self.add_layer(BuildingLayer(layer_blocks, 6))
        del layer_blocks[:]

        ########################################################################
        # level 8
        # TODO: adjust positsions
        layer_blocks.append(
            BuildingBlock(
                Library.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -2),
                block.COBBLESTONE,
                Library.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 2),
                description="Ceiling"))
        # north and south roof eaves
        layer_blocks.append(
            Stair(Library.WALLS_CORNER_POS['North West'] + Vec3(0, 0, 1),
                  block.STAIRS_WOOD.withData(Stair.SOUTH),
                  Library.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 1),
                  description="North roof eaves"))
        layer_blocks.append(
            Stair(Library.WALLS_CORNER_POS['South East'] + Vec3(0, 0, -1),
                  block.STAIRS_WOOD.withData(Stair.NORTH),
                  Library.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -1),
                  description="South roof eaves"))

        self.add_layer(BuildingLayer(layer_blocks, 7))
        del layer_blocks[:]

        ########################################################################
        # level 9
        # TODO: adjust positsions
        # north and south roof eaves
        layer_blocks.append(
            Stair(Library.WALLS_CORNER_POS['North West'] + Vec3(0, 0, 2),
                  block.STAIRS_WOOD.withData(Stair.SOUTH),
                  Library.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 2),
                  description="North roof eaves"))
        layer_blocks.append(
            Stair(Library.WALLS_CORNER_POS['South East'] + Vec3(0, 0, -2),
                  block.STAIRS_WOOD.withData(Stair.NORTH),
                  Library.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -2),
                  description="South roof eaves"))

        self.add_layer(BuildingLayer(layer_blocks, 8))
        del layer_blocks[:]

        ########################################################################
        # add the door
        self.add_block(
            Door(Door.HINGE_LEFT,
                 Vec3(Library.DOOR_POS.x, 1, Library.DOOR_POS.z),
                 block.DOOR_WOOD.withData(Door.SOUTH)))

        self._set_orientation()
コード例 #26
0
	def _create_walls(self):
		builds = []
		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(-4),0,0),
									EXTERIOR_WALLS,
									Building.SE_CORNER_POS + Vec3(self._get_x(-4),WALL_HEIGHT+2,0),
									description="turret wall"))
		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(-5),0,-1),
									EXTERIOR_WALLS,
									Building.SE_CORNER_POS + Vec3(self._get_x(-5),WALL_HEIGHT+2,-1),
									description="turret wall"))
		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(-6),0,-2),
									EXTERIOR_WALLS,
									Building.SE_CORNER_POS + Vec3(self._get_x(-6),WALL_HEIGHT+2,-4),
									description="turret wall"))
		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(-5),0,-5),
									EXTERIOR_WALLS,
									Building.SE_CORNER_POS + Vec3(self._get_x(-5),WALL_HEIGHT+2,-5),
									description="turret wall"))
		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(-4),0,-6),
									EXTERIOR_WALLS,
									Building.SE_CORNER_POS + Vec3(self._get_x(-2),WALL_HEIGHT+2,-6),
									description="turret wall"))
		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(-1),0,-5),
									EXTERIOR_WALLS,
									Building.SE_CORNER_POS + Vec3(self._get_x(-1),WALL_HEIGHT+2,-5),
									description="turret wall"))
		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(0),0,-4),
									EXTERIOR_WALLS,
									Building.SE_CORNER_POS + Vec3(self._get_x(0),WALL_HEIGHT+2,-4),
									description="turret wall"))

		self._add_section("Turret walls", builds)
コード例 #27
0
ファイル: butcher.py プロジェクト: petemulholland/learning
class Butcher(Building):
    """description of class"""

    PEN_CORNERS_POS = {
        'South West': Building.SE_CORNER_POS + Vec3(-6, 0, -7),
        'North West': Building.SE_CORNER_POS + Vec3(-6, 0, -11),
        'North East': Building.SE_CORNER_POS + Vec3(0, 0, -11),
        'South East': Building.SE_CORNER_POS + Vec3(0, 0, -7)
    }

    WALLS_CORNER_POS = {
        'South West': Building.SE_CORNER_POS + Vec3(-8, 0, -1),
        'North West': Building.SE_CORNER_POS + Vec3(-8, 0, -6),
        'North East': Building.SE_CORNER_POS + Vec3(0, 0, -6),
        'South East': Building.SE_CORNER_POS + Vec3(0, 0, -1)
    }

    WINDOW_SPANS = {
        'West': (WALLS_CORNER_POS['South West'] + Vec3(0, 0, -2),
                 WALLS_CORNER_POS['South West'] + Vec3(0, 0, -3)),
        'North': (WALLS_CORNER_POS['North West'] + Vec3(2, 0, 0),
                  WALLS_CORNER_POS['North West'] + Vec3(3, 0, 0)),
        'East': (WALLS_CORNER_POS['South East'] + Vec3(0, 0, -2),
                 WALLS_CORNER_POS['South East'] + Vec3(0, 0, -3)),
        'South': (WALLS_CORNER_POS['South East'] + Vec3(-3, 0, 0),
                  WALLS_CORNER_POS['South East'] + Vec3(-3, 0, 0))
    }

    SOUTH_DOOR_POS = WALLS_CORNER_POS['South East'] + Vec3(-6, 0, 0)
    NORTH_DOOR_POS = WALLS_CORNER_POS['North East'] + Vec3(-2, 0, 0)

    FLOOR_SPANS = ((WALLS_CORNER_POS['South East'] + Vec3(-4, 0, -1),
                    WALLS_CORNER_POS['South East'] + Vec3(-7, 0, -4),
                    block.WOOD_PLANKS),
                   (WALLS_CORNER_POS['South East'] + Vec3(-1, 0, -4),
                    WALLS_CORNER_POS['South East'] + Vec3(-3, 0, -4),
                    block.WOOD_PLANKS),
                   (WALLS_CORNER_POS['South East'] + Vec3(-1, 0, -1),
                    WALLS_CORNER_POS['South East'] + Vec3(-3, 0, -3),
                    block.STONE_SLAB_DOUBLE))

    WIDTH = 9

    def __init__(self, *args, **kwargs):
        super(Butcher, self).__init__(width=Butcher.WIDTH, *args, **kwargs)

        layer_blocks = []
        #######################################################################
        # level 1
        # Pen
        layer_blocks.append(
            BuildingBlock(Butcher.PEN_CORNERS_POS['South West'],
                          block.DIRT,
                          Butcher.PEN_CORNERS_POS['North East'],
                          description="Pen base"))
        walls = []
        # Walls
        walls.append(
            BuildingBlock(Butcher.WALLS_CORNER_POS['South West'],
                          block.COBBLESTONE,
                          Butcher.WALLS_CORNER_POS['North West'],
                          description="West wall base"))
        walls.append(
            BuildingBlock(Butcher.WALLS_CORNER_POS['North West'],
                          block.COBBLESTONE,
                          Butcher.WALLS_CORNER_POS['North East'],
                          description="North wall base"))
        walls.append(
            BuildingBlock(Butcher.WALLS_CORNER_POS['North East'],
                          block.COBBLESTONE,
                          Butcher.WALLS_CORNER_POS['South East'],
                          description="East wall base"))
        walls.append(
            BuildingBlock(Butcher.WALLS_CORNER_POS['South East'],
                          block.COBBLESTONE,
                          Butcher.WALLS_CORNER_POS['South West'],
                          description="South wall base"))
        layer_blocks.extend(walls)

        # floor
        for pos1, pos2, block_type in Butcher.FLOOR_SPANS:
            layer_blocks.append(
                BuildingBlock(pos1, block_type, pos2, description="floor"))

        # door steps
        layer_blocks.append(
            Stair(Butcher.SOUTH_DOOR_POS + Vec3(0, 0, 1),
                  block.STAIRS_COBBLESTONE.withData(Stair.NORTH),
                  description="Front door step"))
        layer_blocks.append(
            BuildingBlock(Butcher.NORTH_DOOR_POS + Vec3(0, 0, -1),
                          block.COBBLESTONE,
                          description="Pen door step"))

        self.add_layer(BuildingLayer(layer_blocks, 0))
        del layer_blocks[:]

        #######################################################################
        # level 2
        # Pen fences
        layer_blocks.append(
            BuildingBlock(Butcher.PEN_CORNERS_POS['South West'],
                          block.FENCE,
                          Butcher.PEN_CORNERS_POS['North West'],
                          description="West pen fence"))
        layer_blocks.append(
            BuildingBlock(Butcher.PEN_CORNERS_POS['North West'],
                          block.FENCE,
                          Butcher.PEN_CORNERS_POS['North East'],
                          description="North pen fence"))
        layer_blocks.append(
            BuildingBlock(Butcher.PEN_CORNERS_POS['North East'],
                          block.FENCE,
                          Butcher.PEN_CORNERS_POS['South East'],
                          description="East pen fence"))
        # Walls
        layer_blocks.extend(walls)
        layer_blocks.append(
            BuildingBlock(Butcher.SOUTH_DOOR_POS,
                          block.AIR,
                          description="Clear front door"))
        layer_blocks.append(
            BuildingBlock(Butcher.NORTH_DOOR_POS,
                          block.AIR,
                          description="Clear pen door"))

        # table
        layer_blocks.append(
            BuildingBlock(Butcher.WALLS_CORNER_POS['North West'] +
                          Vec3(1, 0, 1),
                          block.WOOD_PLANKS,
                          description="Table area corner"))
        layer_blocks.append(
            BuildingBlock(Butcher.WALLS_CORNER_POS['North West'] +
                          Vec3(2, 0, 2),
                          block.FENCE,
                          description="Table base"))
        layer_blocks.append(
            Stair(Butcher.WALLS_CORNER_POS['North West'] + Vec3(1, 0, 2),
                  block.STAIRS_WOOD.withData(Stair.WEST),
                  description="West seat"))
        layer_blocks.append(
            Stair(Butcher.WALLS_CORNER_POS['North West'] + Vec3(2, 0, 1),
                  block.STAIRS_WOOD.withData(Stair.NORTH),
                  description="North seat"))

        # counter
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['South East'] + Vec3(-2, 0, -1),
                block.STONE_SLAB_DOUBLE,
                Butcher.WALLS_CORNER_POS['South East'] + Vec3(-2, 0, -2),
                description="Counter"))

        self.add_layer(BuildingLayer(layer_blocks, 1))
        del layer_blocks[:]

        #######################################################################
        # level 3
        # corners
        for key, pos in Butcher.WALLS_CORNER_POS.items():
            layer_blocks.append(
                BuildingBlock(pos,
                              block.COBBLESTONE,
                              description=key + " corner"))
        # north and south walls
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['North West'] + Vec3(1, 0, 0),
                block.WOOD_PLANKS,
                Butcher.WALLS_CORNER_POS['North East'] + Vec3(-1, 0, 0),
                description="North wall"))
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['South West'] + Vec3(1, 0, 0),
                block.WOOD_PLANKS,
                Butcher.WALLS_CORNER_POS['South East'] + Vec3(-1, 0, 0),
                description="South wall"))

        # east and west walls
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -1),
                block.WOOD,
                Butcher.WALLS_CORNER_POS['North West'] + Vec3(0, 0, 1),
                description="West wall"))
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['South East'] + Vec3(0, 0, -1),
                block.WOOD,
                Butcher.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 1),
                description="East wall"))

        # windows
        for key, span in Butcher.WINDOW_SPANS.items():
            # clear the space first:
            layer_blocks.append(
                BuildingBlock(span[0],
                              block.GLASS_PANE,
                              span[1],
                              description=key + " window"))

        layer_blocks.append(
            BuildingBlock(Butcher.SOUTH_DOOR_POS,
                          block.AIR,
                          description="Clear front door"))
        layer_blocks.append(
            BuildingBlock(Butcher.NORTH_DOOR_POS,
                          block.AIR,
                          description="Clear pen door"))

        # TODO: table top
        layer_blocks.append(
            BuildingBlock(Butcher.WALLS_CORNER_POS['North West'] +
                          Vec3(2, 0, 2),
                          TABLE_TOP,
                          description="Table top"))

        self.add_layer(BuildingLayer(layer_blocks, 2))
        del layer_blocks[:]

        #######################################################################
        # level 4
        # east & west stone walls
        layer_blocks.append(
            BuildingBlock(Butcher.WALLS_CORNER_POS['South West'],
                          block.COBBLESTONE,
                          Butcher.WALLS_CORNER_POS['North West'],
                          description="West wall"))
        layer_blocks.append(
            BuildingBlock(Butcher.WALLS_CORNER_POS['South East'],
                          block.COBBLESTONE,
                          Butcher.WALLS_CORNER_POS['North East'],
                          description="East wall"))
        # north and south wood walls
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['North West'] + Vec3(1, 0, 0),
                block.WOOD_PLANKS,
                Butcher.WALLS_CORNER_POS['North East'] + Vec3(-1, 0, 0),
                description="North wall"))
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['South West'] + Vec3(1, 0, 0),
                block.WOOD_PLANKS,
                Butcher.WALLS_CORNER_POS['South East'] + Vec3(-1, 0, 0),
                description="South wall"))

        # north and south roof eaves
        layer_blocks.append(
            Stair(Butcher.WALLS_CORNER_POS['North West'] + Vec3(0, 0, -1),
                  block.STAIRS_WOOD.withData(Stair.SOUTH),
                  Butcher.WALLS_CORNER_POS['North East'] + Vec3(0, 0, -1),
                  description="North roof eaves"))
        layer_blocks.append(
            Stair(Butcher.WALLS_CORNER_POS['South East'] + Vec3(0, 0, 1),
                  block.STAIRS_WOOD.withData(Stair.NORTH),
                  Butcher.WALLS_CORNER_POS['South West'] + Vec3(0, 0, 1),
                  description="South roof eaves"))
        # torches over doors
        layer_blocks.append(
            Torch(Butcher.SOUTH_DOOR_POS + Vec3(0, 0, -1),
                  block.TORCH.withData(Torch.NORTH),
                  description="Torch over front door"))
        layer_blocks.append(
            Torch(Butcher.NORTH_DOOR_POS + Vec3(0, 0, 1),
                  block.TORCH.withData(Torch.SOUTH),
                  description="Torch over pen door"))

        self.add_layer(BuildingLayer(layer_blocks, 3))
        del layer_blocks[:]

        #######################################################################
        # level 5
        # east & west gables
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -1),
                block.WOOD_PLANKS,
                Butcher.WALLS_CORNER_POS['North West'] + Vec3(0, 0, 1),
                description="West gable"))
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 1),
                block.WOOD_PLANKS,
                Butcher.WALLS_CORNER_POS['South East'] + Vec3(0, 0, -1),
                description="East gable"))
        # north and south rafters
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['North West'] + Vec3(0, 0, 1),
                block.WOOD_PLANKS,
                Butcher.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 1),
                description="North rafters"))
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['South East'] + Vec3(0, 0, -1),
                block.WOOD_PLANKS,
                Butcher.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -1),
                description="South rafters"))

        # north and south roof
        layer_blocks.append(
            Stair(Butcher.WALLS_CORNER_POS['North West'],
                  block.STAIRS_WOOD.withData(Stair.SOUTH),
                  Butcher.WALLS_CORNER_POS['North East'],
                  description="North roof"))
        layer_blocks.append(
            Stair(Butcher.WALLS_CORNER_POS['South East'],
                  block.STAIRS_WOOD.withData(Stair.NORTH),
                  Butcher.WALLS_CORNER_POS['South West'],
                  description="South roof"))

        self.add_layer(BuildingLayer(layer_blocks, 4))
        del layer_blocks[:]

        #######################################################################
        # level 6
        # rafters
        layer_blocks.append(
            BuildingBlock(
                Butcher.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -2),
                block.WOOD_PLANKS,
                Butcher.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 2),
                description="Rafters"))

        # north and south roof
        layer_blocks.append(
            Stair(Butcher.WALLS_CORNER_POS['North West'] + Vec3(0, 0, 1),
                  block.STAIRS_WOOD.withData(Stair.SOUTH),
                  Butcher.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 1),
                  description="North roof"))
        layer_blocks.append(
            Stair(Butcher.WALLS_CORNER_POS['South East'] + Vec3(0, 0, -1),
                  block.STAIRS_WOOD.withData(Stair.NORTH),
                  Butcher.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -1),
                  description="South roof"))

        self.add_layer(BuildingLayer(layer_blocks, 5))
        del layer_blocks[:]

        #######################################################################
        # level 7
        # north and south roof
        layer_blocks.append(
            Stair(Butcher.WALLS_CORNER_POS['North West'] + Vec3(0, 0, 2),
                  block.STAIRS_WOOD.withData(Stair.SOUTH),
                  Butcher.WALLS_CORNER_POS['North East'] + Vec3(0, 0, 2),
                  description="North roof"))
        layer_blocks.append(
            Stair(Butcher.WALLS_CORNER_POS['South East'] + Vec3(0, 0, -2),
                  block.STAIRS_WOOD.withData(Stair.NORTH),
                  Butcher.WALLS_CORNER_POS['South West'] + Vec3(0, 0, -2),
                  description="South roof"))

        self.add_layer(BuildingLayer(layer_blocks, 6))
        del layer_blocks[:]

        # add the door
        self.add_block(
            Door(None,
                 Vec3(Butcher.SOUTH_DOOR_POS.x, 1, Butcher.SOUTH_DOOR_POS.z),
                 block.DOOR_WOOD.withData(Door.SOUTH)))

        self.add_block(
            Door(None,
                 Vec3(Butcher.NORTH_DOOR_POS.x, 1, Butcher.NORTH_DOOR_POS.z),
                 block.DOOR_WOOD.withData(Door.NORTH)))

        self._set_orientation()
コード例 #28
0
	def _create_stairs(self):
		builds = []

		# north facing stairs, supports & landing
		builds.append(Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-1),0,-3), 
							block.STAIRS_WOOD.withData(Stair.NORTH), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-2),0,-3), 
							description="Stair"))

		support = Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-1),0,-4), 
							block.STAIRS_WOOD.withData(Stair.SOUTH), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-2),0,-4), 
							description="Support")
		support.invert()
		builds.append(support)
		builds.append(Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-1),1,-4), 
							block.STAIRS_WOOD.withData(Stair.NORTH), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-2),1,-4), 
							description="Stair"))

		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(-2),1,-5),
									block.WOOD_PLANKS,
									description="landing"))

		# east facing stairs, supports & landing
		stair_direction = Stair.WEST
		support_direction = Stair.EAST
		if self.mirrored:
			stair_direction = Stair.EAST
			support_direction = Stair.WEST


		support = Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-3),1,-4), 
							block.STAIRS_WOOD.withData(support_direction), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-3),1,-5), 
							description="Support")
		support.invert()
		builds.append(support)
		builds.append(Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-3),2,-4), 
							block.STAIRS_WOOD.withData(stair_direction), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-3),2,-5), 
							description="Stair"))

		support = Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-4),2,-4), 
							block.STAIRS_WOOD.withData(support_direction), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-4),2,-5), 
							description="Support")
		support.invert()
		builds.append(support)
		builds.append(Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-4),3,-4), 
							block.STAIRS_WOOD.withData(stair_direction), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-4),3,-5), 
							description="Stair"))

		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(-5),3,-4),
									block.WOOD_PLANKS,
									description="landing"))


		# south facing stairs, supports & landing
		support = Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-4),3,-3), 
							block.STAIRS_WOOD.withData(Stair.NORTH), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-5),3,-3), 
							description="Support")
		support.invert()
		builds.append(support)
		builds.append(Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-4),4,-3), 
							block.STAIRS_WOOD.withData(Stair.SOUTH), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-5),4,-3), 
							description="Stair"))

		support = Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-4),4,-2), 
							block.STAIRS_WOOD.withData(Stair.NORTH), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-5),4,-2), 
							description="Support")
		support.invert()
		builds.append(support)
		builds.append(Stair(Building.SE_CORNER_POS + Vec3(self._get_x(-4),5,-2), 
							block.STAIRS_WOOD.withData(Stair.SOUTH), 
							Building.SE_CORNER_POS + Vec3(self._get_x(-5),5,-2), 
							description="Stair"))

		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(-4),5,-1),
									block.WOOD_PLANKS,
									description="landing"))

		builds.append(BuildingBlock(Building.SE_CORNER_POS + Vec3(self._get_x(-3),5,-1),
									block.WOOD_PLANKS,
									Building.SE_CORNER_POS + Vec3(self._get_x(-3),5,-2),
									description="landing extension"))

		self._add_section("Turret stairs", builds)
コード例 #29
0
from mcpi.minecraft import Minecraft
from mcpi.vec3 import Vec3

mc = Minecraft.create()

pos_1 = Vec3(257, -9, -52)
pos_2 = Vec3(259, -5, -48)

pos_new = Vec3(267, 0, -42)

for x in range(pos_2.x - pos_1.x + 1):
    for y in range(pos_2.y - pos_1.y + 1):
        for z in range(pos_2.z - pos_1.z + 1):
            shift = Vec3(x, y, z)
            block = mc.getBlockWithData(pos_1 + shift)
            mc.setBlock(pos_new + shift, block)
コード例 #30
0
 def test_rotate_left(self):
     v = Vec3(2, -3, 8)
     v.rotateLeft()
     expect_vec = Vec3(8, -3, -2)
     assert v == expect_vec