def __init__(self, *args, **kwargs): super(Farm, self).__init__(width=Farm.WIDTH, *args, **kwargs) layer_blocks = [] layer_blocks.append(BuildingBlock(Farm.BOUNDARY_SPAN[0], block.WOOD, Farm.BOUNDARY_SPAN[1], description="Farm boundary")) layer_blocks.append(BuildingBlock(Farm.LAND_SPAN[0], block.FARMLAND, Farm.LAND_SPAN[1], description="Farm land")) layer_blocks.append(BuildingBlock(Farm.WATER_SPAN[0], block.WATER, Farm.WATER_SPAN[1], description="Farm irrigation")) self.add_layer(BuildingLayer(layer_blocks, 0)) del layer_blocks[:] # all wheat on one side , with random choice of ripeness layer_blocks.append(BuildingBlock(Farm.CROPS_LEFT_SPAN[0], Block(WHEAT.id, random.randint(3,7)), Farm.CROPS_LEFT_SPAN[1], description="Wheat crops")) layer_blocks.append(BuildingBlock(Farm.CROPS_RIGHT_SPAN[0], Block(POTATOES.id, random.randint(3,7)), Farm.CROPS_RIGHT_SPAN[1] + Vec3(1,0,0), description="Potatoes")) layer_blocks.append(BuildingBlock(Farm.CROPS_RIGHT_SPAN[0] + Vec3(-1,0,0,), Block(CARROTS.id, random.randint(3,7)), Farm.CROPS_RIGHT_SPAN[1], description="Carrots")) self.add_layer(BuildingLayer(layer_blocks, 1)) self._set_orientation()
def __init__(self, attribs): super(GpioSource, self).__init__() self.pin = attribs["pin"] self.low_state_block = Block(attribs["low_state_block"][0], attribs["low_state_block"][1]) self.high_state_block = Block(attribs["high_state_block"][0], attribs["high_state_block"][1]) GpioSource.gpio_in_setup(self.pin)
def __init__(self, mc, pos, height, maxLength, minValue, maxValue, blocksToUse=None, xIncrement=1, zIncrement=0): #store the values of the bar graph self.mc = mc self.pos = pos self.height = height self.maxLength = maxLength self.minValue = minValue self.maxValue = maxValue if blocksToUse == None: blocksToUse = [] for col in range(0, 15): blocksToUse.append(Block(block.WOOL.id, col)) self.blocksToUse = blocksToUse self.xIncrement = xIncrement self.zIncrement = zIncrement self.currentBlock = 0 #set the position of the next bar in the graph self.barPos = pos.clone() self.graphLength = 0
def __init__(self, mc, pos, maxRadius, minValue, maxValue, blocksToUse=None, angleIncrement=ANGLEINCREMENT): self.mc = mc self.pos = pos self.maxRadius = maxRadius self.minValue = minValue self.maxValue = maxValue #if no blocks to use have been passed, set them to the wool colours if blocksToUse == None: blocksToUse = [] for col in range(0, 15): blocksToUse.append(Block(block.WOOL.id, col)) self.blocksToUse = blocksToUse self.angleIncrement = angleIncrement self.currentBlock = 0 self.angle = 0 #create a dictionary of the lines for the angles in the circle # to keep track of the values so they can be cleared self.lines = {} #create the minecraft drawing object which will be used to draw the lines self.draw = MinecraftDrawing(mc)
def clone(self): new_pos2 = None assert self.block.id in Wood.VALID_IDS, "Invalid block id for Torch: {0}".format( self.block.id) return Wood(self.pos.clone(), Block(self.block.id).withData(self.block.data), self.description)
def clone(self): new_pos2 = None assert self.block.id == HOPPER.id, "Invalid block id for Hopper: {0}".format( self.block.id) return Hopper(self.pos.clone(), Block(self.block.id).withData(self.block.data), self.description)
def add_numpy_array_to_minecraft(minecraft_conn, start_coordinates, bio_complex): """ """ bin_count_df, item_info = bio_complex for idx, row in bin_count_df.iterrows(): coord = row[['x_coord', 'y_coord', 'z_coord']] + start_coordinates info = item_info[row['id']] texture = int(info['texture']) color = int(info['color']) minecraft_conn.setBlock(coord.tolist(), Block(texture, color))
from building import Building, BuildingEx, BuildingBlock, SubBuilding, Torch, Stair, Door from base.fixtures import Fireplace from base.constants import EXTERIOR_WALLS, WALL_HEIGHT from building.types import PlankData import mcpi.block as block from mcpi.block import Block from mcpi.vec3 import Vec3 # http://minecraft.gamepedia.com/Data_values#Block_IDs HALL_FLOOR = block.WOOD_PLANKS.withData(PlankData.SPRUCE) HALL_FACIA = block.WOOD_PLANKS.withData(PlankData.JUNGLE) TABLE_TOP = Block(171, 12) TABLE_PLACE = Block(171, 0) # TODO: rework positions with laid out plan for castle ground floor. # class DiningHall(BuildingEx): # TODO: implement table & chairs, fireplaces & paintings on walls #- dining hall # - table 9x3 # - +1 around for chairs # - +2 all around to leave space for ornaments # - carpet on table at chair positions for place settings # - => 13 x 9 # - maybe 15 to 17 long for fireplaces at both ends - 20 long? # 17 x 9 for fireplaces, # stone walls & wooden facian on interior => 21 x 13 WALLS_CORNER_POS = {'South East' : Building.SE_CORNER_POS + Vec3(0,0,0), 'South West' : Building.SE_CORNER_POS + Vec3(-27,0,0),
from building import Building, BuildingLayer, BuildingBlock, TABLE_TOP, Stair, Furnace, Chest import mcpi.block as block from mcpi.block import Block from mcpi.vec3 import Vec3 IRON_BARS = Block(101) class Blacksmith(Building): """description of class""" WALLS_CORNER_POS = { 'South East': Building.SE_CORNER_POS + Vec3(0, 0, -1), 'South West': Building.SE_CORNER_POS + Vec3(-9, 0, -1), 'North West': Building.SE_CORNER_POS + Vec3(-9, 0, -7), 'North East': Building.SE_CORNER_POS + Vec3(0, 0, -7) } STAIR_SPAN = (WALLS_CORNER_POS['South West'] + Vec3(1, 0, 1), WALLS_CORNER_POS['South West'] + Vec3(3, 0, 1)) LAVAPIT_SPAN = (WALLS_CORNER_POS['North West'], WALLS_CORNER_POS['North West'] + Vec3(3, 0, 2)) LAVA_SPAN = (WALLS_CORNER_POS['North West'] + Vec3(1, 0, 1), WALLS_CORNER_POS['North West'] + Vec3(2, 0, 1)) FURNACE_POS = WALLS_CORNER_POS['North West'] + Vec3(3, 0, 3) CORNER_POSTS = (WALLS_CORNER_POS['South East'], WALLS_CORNER_POS['North East'], WALLS_CORNER_POS['South East'] + Vec3(-3, 0, 0)) FENCES_POS = (WALLS_CORNER_POS['South West'],
def __init__(self, *args, **kwargs): super(ApartmentBlock, self).__init__(width=ApartmentBlock.WIDTH, *args, **kwargs) builds = [] ####################################################################### # build entire apt block from spans: # "concrete" structure (smooth stone) builds.append( BuildingBlock(ApartmentBlock.APT_BLOCK_SPAN[0], block.STONE, ApartmentBlock.APT_BLOCK_SPAN[1], description="Apt block stone super structure")) # 17 apt wall sections per floor can be done using 5 wood spans & 6 interior spaces # build wood plank spans for key, span in ApartmentBlock.WOOD_PLANK_SPANS.items(): for pos in ApartmentBlock.WOOD_PLANK_POS[key]: # ground floor builds.append( BuildingBlock(span[0] + pos, block.WOOD_PLANKS, span[1] + pos, description="%s wood span ground floor" % (key))) # 2nd floor builds.append( BuildingBlock(span[0] + pos + Vec3(0, 4, 0), block.WOOD_PLANKS, span[1] + pos + Vec3(0, 4, 0), description="%s wood span 2nd floor" % (key))) # clear apt interiors (this will leave concrete floors & ceilings) for pos in ApartmentBlock.APT_INTERIOR_POS: # ground floor builds.append( BuildingBlock(ApartmentBlock.APT_INTERIOR_SPAN[0] + pos, block.AIR, ApartmentBlock.APT_INTERIOR_SPAN[1] + pos, description="Clear apt interior ground floor")) # 2nd floor builds.append( BuildingBlock( ApartmentBlock.APT_INTERIOR_SPAN[0] + pos + Vec3(0, 4, 0), block.AIR, ApartmentBlock.APT_INTERIOR_SPAN[1] + pos + Vec3(0, 4, 0), description="Clear apt interior 2nd floor")) # add torch to SW croner of block to indicte when this section has completed buiding in game #builds.append(Torch(Vec3(-11,3,-3), block.TORCH.withData(Torch.WEST), # description="section complete indicator")) self._add_section("Apt block super structure", builds) # doors & torches # TODO: debug this: East side apartments have doors "facing" east (built on east side of block) # East side apts torches should face west, but applied on east face of containing block (west face of support block) # TODO: add doc strings to doors and torches on what the orientation means for pos in ApartmentBlock.APT_DOORS_POS["East"]: # ground floor builds.append( Door(Door.HINGE_RIGHT, pos, block.DOOR_WOOD.withData(Door.EAST), description="Ground floor door east side")) builds.append( Torch(pos + Vec3(-1, 2, 0), block.TORCH.withData(Torch.WEST), description="Ground floor interior torch")) builds.append( Torch(pos + Vec3(1, 2, 0), block.TORCH.withData(Torch.EAST), description="Ground floor exterior torch")) # 2nd floor builds.append( Door(Door.HINGE_RIGHT, pos + Vec3(0, 4, 0), block.DOOR_WOOD.withData(Door.EAST), description="2nd floor door east side")) builds.append( Torch(pos + Vec3(-1, 6, 0), block.TORCH.withData(Torch.WEST), description="2nd floor interior torch")) builds.append( Torch(pos + Vec3(1, 6, 0), block.TORCH.withData(Torch.EAST), description="2nd floor exterior torch")) for pos in ApartmentBlock.APT_DOORS_POS["West"]: # ground floor builds.append( Door(Door.HINGE_LEFT, pos, block.DOOR_WOOD.withData(Door.WEST), description="Ground floor door west side")) builds.append( Torch(pos + Vec3(1, 2, 0), block.TORCH.withData(Torch.EAST), description="Ground floor interior torch")) builds.append( Torch(pos + Vec3(-1, 2, 0), block.TORCH.withData(Torch.WEST), description="Ground floor exterior torch")) # 2nd floor builds.append( Door(Door.HINGE_LEFT, pos + Vec3(0, 4, 0), block.DOOR_WOOD.withData(Door.WEST), description="2nd floor door west side")) builds.append( Torch(pos + Vec3(1, 6, 0), block.TORCH.withData(Torch.EAST), description="2nd floor interior torch")) builds.append( Torch(pos + Vec3(-1, 6, 0), block.TORCH.withData(Torch.WEST), description="2nd floor exterior torch")) # windows for pos in ApartmentBlock.APT_WINS_POS: builds.append( BuildingBlock(pos, block.GLASS_PANE, description="ground floor window")) builds.append( BuildingBlock(pos + Vec3(0, 4, 0), block.GLASS_PANE, description="2nd floor window")) # add torch to SW croner of block to indicte when this section has completed buiding in game #builds.append(Torch(Vec3(-11,2,-3), block.TORCH.withData(Torch.WEST), # description="section complete indicator")) self._add_section("Apt block fittings", builds) ####################################################################### # Ground floor walkway & steps # stone walk way builds.extend(self._add_walkway(block.STONE, 0)) # stone steps at end of each walkway # TODO: block data for stone brick stairs builds.append( Stair(ApartmentBlock.CORNER_POS['South East'] + Vec3(0, 0, 1), Block(109).withData(Stair.NORTH), ApartmentBlock.CORNER_POS['South East'] + Vec3(-1, 0, 1), description="Ground floor steps")) builds.append( Stair(ApartmentBlock.CORNER_POS['South West'] + Vec3(1, 0, 1), Block(109).withData(Stair.NORTH), ApartmentBlock.CORNER_POS['South West'] + Vec3(0, 0, 1), description="Ground floor steps")) self._add_section("Ground floor walkway", builds) ####################################################################### # Support posts for 2nd floor walkway for pos in ApartmentBlock.CORNER_POS.values(): builds.append( BuildingBlock(pos + Vec3(0, 1, 0), block.FENCE, pos + Vec3(0, 3, 0), description="Corner post")) self._add_section("2nd floor support posts", builds) ####################################################################### # 2nd floor walkway # wooden walk way around 2nd floor builds.extend(self._add_walkway(block.WOOD_PLANKS, 4)) self._add_section("2nd floor wooden walkway", builds) ####################################################################### # Stairs to 2nd floor for i in range(0, 5): # wooden steps to 2nd floor. builds.append( Stair(ApartmentBlock.CORNER_POS['South East'] + Vec3(-8 + i, i, 1), block.STAIRS_WOOD.withData(Stair.EAST), description="Steps to upper floor")) # TODO: figure out block data for upside down stairs and use this instead of support block builds.append( BuildingBlock(ApartmentBlock.CORNER_POS['South East'] + Vec3(-7 + i, i, 1), block.WOOD_PLANKS, description="stair support")) self._add_section("Stairs to 2nd floor", builds) ####################################################################### if DO_2ND_FLOOR_RAILINGS: # 2nd floor walkway railings (should extend these out by 1 block all around so walkway is 2 blocks wide) # west side railings builds.append( BuildingBlock( ApartmentBlock.CORNER_POS['North West'] + Vec3(0, 5, 0), block.FENCE, ApartmentBlock.CORNER_POS['South West'] + Vec3(0, 5, 0), description="Balcony railings")) # close off west side railings on north end builds.append( BuildingBlock(ApartmentBlock.CORNER_POS['North West'] + Vec3(1, 5, 0), block.FENCE, description="Balcony railings")) # east side railings builds.append( BuildingBlock( ApartmentBlock.CORNER_POS['North East'] + Vec3(0, 5, 0), block.FENCE, ApartmentBlock.CORNER_POS['South East'] + Vec3(0, 5, 0), description="Balcony railings")) # close off east side railings on north end builds.append( BuildingBlock(ApartmentBlock.CORNER_POS['North East'] + Vec3(-1, 5, 0), block.FENCE, description="Balcony railings")) # south balcony railings builds.append( BuildingBlock( ApartmentBlock.CORNER_POS['South East'] + Vec3(0, 5, 0), block.FENCE, ApartmentBlock.CORNER_POS['South East'] + Vec3(-5, 5, 0), description="Balcony railings")) builds.append( BuildingBlock( ApartmentBlock.CORNER_POS['South West'] + Vec3(0, 5, 0), block.FENCE, ApartmentBlock.CORNER_POS['South West'] + Vec3(6, 5, 0), description="Balcony railings")) self._add_section("2nd floor railings", builds) ####################################################################### # Add the streets between as subbuildings street_ew = Street(9, Building.WEST) street_ns = Street(8, Building.NORTH) builds.append( SubBuilding(street_ew, Building.SE_CORNER_POS + Vec3(0, 0, 1))) builds.append( SubBuilding(street_ew, Building.SE_CORNER_POS + Vec3(0, 0, -24))) builds.append( SubBuilding(street_ns, Building.SE_CORNER_POS + Vec3(-13, 0, 0))) self._add_section("Streets", builds) ####################################################################### # Add the farm subbuildings farms = [Farm(Building.WEST), LargeFarm(Building.NORTH)] for pos in ApartmentBlock.WEST_FARMS_POS: builds.append(SubBuilding(farms[0], pos)) self._add_section("West Farms", builds) for pos in ApartmentBlock.NORTH_FARMS_POS: builds.append(SubBuilding(farms[1], pos)) self._add_section("North Double Farms", builds) ####################################################################### self._set_orientation()
from mineturtle import * from mcpi.block import Block import sys t = Turtle() t.pendelay(0) if len(sys.argv) >= 2: radius = int(sys.argv[1]) else: radius = 10 if len(sys.argv) >= 3: material = Block.byName(sys.argv[2]) else: material = block.GOLD_BLOCK t.penwidth(2 * radius) t.penblock(material) t.go(0) t.pitch(90) t.penup() t.go(radius + 2)
from building import Building, BuildingEx, BuildingBlock, Torch import mcpi.block as block from mcpi.block import Block from mcpi.vec3 import Vec3 SUGAR_CANE = Block(83, 15) # 15 => first level is fully mature class SugarCaneFarm(Building): # TODO: implement single cane farm with pistons & surrounding redstone pass class DoubleCaneFarm(BuildingEx): # TODO double up the cane farm with redstoen path overlapping and 1 button to activate pistons. pass
def poll_state(self): with open(self.file_name, "r") as file_: contents = file_.read() parsed = contents.split(",") return Block(id=int(parsed[0]), data=int(parsed[1]))
def getBlockWithData(self, *args): """Get block with data (x,y,z) => Block""" ans = self.conn.sendReceive(b"world.getBlockWithData", intFloor(args)) return Block(*list(map(int, ans.split(","))))
from building import Building, BuildingEx, BuildingBlock, Torch import mcpi.block as block from mcpi.block import Block from mcpi.vec3 import Vec3 WHEAT = Block(59) POTATOES = Block(142) CARROTS = Block(391) class CropFarm(Building): # TODO: implement my current deisgn 7x8 with dispensers on bottom at back of 8 long side # surrounded on 3 sides & top by glass # run redstone around pass class DoubleCropFarm(BuildingEx): WIDTH = 19 # TODO add 2 farms 1 east, 1 west (use case for mirroring so redstone all comes to same side. # add central collection channel # fill gap & add water channel. # add redtone mech for button to operate dispensers # add hoppers & chest for collection # add door & trapdoor over collection channel # take 2 init params for crops left & crops right pass