def perform(level,box, options): ''' Feedback to [email protected] ''' # Local variables method = options["Operation"] (method, (width, height, depth), (centreWidth, centreHeight, centreDepth)) = FuncStart(level,box,options,method) # Log start level0 = level.extractSchematic(box) # Copy the area of interest into a working area, mostly for 'speed' box0 = BoundingBox((0,0,0),(width,height,depth)) b=range(4096) b.remove(0) # @CodeWarrior0 and @Wout12345 explained how to merge schematics if method == "Islands": for i in xrange(0,1000): print i radius = randint(10,50) centrex = randint(radius+2,width-radius-2) centrez = randint(radius+2,depth-radius-2) maxy = randint(radius+2,height-radius-2) theBox = BoundingBox((0,0,0),(2*radius-1,maxy-1,2*radius-1)) theObj = MCSchematic((2*radius-1,maxy-1,2*radius-1)) island(theObj,theBox,options) level0.copyBlocksFrom(theObj, theBox, (box0.minx+centrex-radius,box0.miny,box0.minz+centrez-radius),b) elif method == "Island": theBox = BoundingBox((0,0,0),(width,height,depth)) theObj = MCSchematic((width,height,depth)) island(theObj, theBox, options) level0.copyBlocksFrom(theObj, theBox, (box0.minx,box0.miny,box0.minz),b) level.copyBlocksFrom(level0, box0, (box.minx, box.miny, box.minz )) # Copy the working area back into the world level.markDirtyBox(box) FuncEnd(level,box,options,method) # Log end
def Surface(level,box,spacing): op = "Surface" #level2 = level.extractSchematic(box) # Working set level2 = MCSchematic((box.width,box.height,box.length)) box2 = BoundingBox((0,0,0),(box.width,box.height,box.length)) airlevel = MCSchematic((box.width,box.height,box.length)) airbox = BoundingBox((0,0,0),(box.width,box.height,box.length)) for x in xrange(box.minx,box.maxx): if x%10 == 0: print str(time.ctime())+" Scanning for surfaces "+op+" "+str(x) for z in xrange(box.minz,box.maxz): for y in xrange(box.miny,box.maxy): if getBlock(level,x,y,z) != (0,0): for ddx in xrange(-1,2): for ddz in xrange(-1,2): for ddy in xrange(-1,2): if not (ddx == 0 and ddy == 0 and ddz == 0): if getBlock(level,x+ddx,y+ddy,z+ddz) == (0,0): setBlock(airlevel,(1,0),x-box.minx,y-box.miny,z-box.minz) # Adjacent to air / surface else: setBlock(airlevel,(2,0),x-box.minx,y-box.miny,z-box.minz) # Airblock here for x in xrange(box.minx,box.maxx): if x%10 == 0: print str(time.ctime())+" Running "+op+" "+str(x) for z in xrange(box.minz,box.maxz): for y in xrange(box.miny,box.maxy): if getBlock(airlevel,x-box.minx,y-box.miny,z-box.minz) == (1,0): # This is a surface block setBlock(level2,getBlock(level,x,y,z),x-box.minx,y-box.miny,z-box.minz) level.copyBlocksFrom(level2, box2, (box.minx, box.miny, box.minz ))
def perform(level, box, options): print "ALife generation: Start." width = box.maxx - box.minx height = box.maxy - box.miny depth = box.maxz - box.minz material = getBlockFromOptions(options, "Material:") b = range(4096) b.remove( 0) # @CodeWarrior0 and @Wout12345 explained how to merge schematics planes = [] prevTickPlane = MCSchematic((width, height, depth)) print options["Mode"] if options["Mode"] == "Randomise": # Randomise to initialise initialise(prevTickPlane, options["Initial chance:"], material) elif options["Mode"] == "Load image": # Use black pixels to seed the generation initialiseFromImageFile( prevTickPlane, options["File path"], material, (options["Red"], options["Green"], options["Blue"])) else: # Use what's in the lowest plane of the selection box (i.e. the SOUTH most layer). Not air equals an alive cell. prevTickPlane = level.extractSchematic( BoundingBox((box.minx, box.miny, box.minz), (width, height, 1))) numTicksToRun = options["Number of ticks"] if numTicksToRun > depth: numTicksToRun = depth level.copyBlocksFrom(prevTickPlane, BoundingBox((0, 0, 0), (width, height, 1)), (box.minx, box.miny, box.minz), b) #First layer for z in xrange(1, numTicksToRun): print "Ticking", z TickPlane = MCSchematic((width, height, depth)) calculateLifeTick(prevTickPlane, TickPlane, material) # planes.append(TickPlane) # History level.copyBlocksFrom(TickPlane, BoundingBox((0, 0, 0), (width, height, 1)), (box.minx, box.miny, box.minz + z), b) prevTickPlane = TickPlane if options[ "Mode"] == "File path": # Save the last plane so it can be the next input if required. img.save(options["File path"] + "_end.png") level.markDirtyBox(box) print "ALife generation: Done." print "Complete!"
def placeASchematic(x, y, z, theFileName, level, box, options): # CONSTANTS AND GLOBAL VARIABLES method = "placeASchematic" print '%s: Started at %s' % (method, time.ctime()) (width, height, depth) = getBoxSize(box) centreWidth = width >> 1 centreHeight = height >> 1 centreDepth = depth >> 1 removeAir = options["Remove air?"] # END CONSTANTS # cursorPosn = box.origin # import the corresponding MCSchematic to the supplied filename print 'Loading schematic from file - %s' % (theFileName) charSchematic = MCSchematic(filename=theFileName) schemWidthOffset = charSchematic.Width >> 1 schemDepthOffset = charSchematic.Length >> 1 cursorPosn = (x - schemWidthOffset, y, z - schemDepthOffset) blocksIDs = range(level.materials.id_limit) if removeAir: blocksIDs.remove(0) level.copyBlocksFrom( charSchematic, BoundingBox( (0, 0, 0), (charSchematic.Width, charSchematic.Height, charSchematic.Length)), cursorPosn, blocksToCopy=blocksIDs) print '%s: Ended at %s' % (method, time.ctime())
def build(block_space): """ Build a blockspace into a schematic :param block_space: Blockspace :return: MCSchematic containing all the blocks described in the blockspace. """ # Create a schematic of the size of the blockspace. schematic = MCSchematic(shape=block_space.size) tile_entities_to_add = [] for block, location in block_space.packed_blocks.items(): # Create the actual block. if block.has_tile_entity: # Create the tile mcentity of the block, if it has one. tile_entity = translate(block, location, blockspace=block_space) tile_entities_to_add.append(tile_entity) schematic.setBlockAt(location[0], location[1], location[2], block.block_id) data_value = calculate_data_value(block) if data_value is not None: schematic.setBlockDataAt(location[0], location[1], location[2], data_value) for tile_entity in tile_entities_to_add: schematic.addTileEntity(tile_entity) return schematic
def farm(): e = MCSchematic(shape=(9, 2, 7), filename='') e._Blocks = [[[17, 17, 17, 17, 17, 17, 17, 17, 17], [17, 60, 60, 60, 60, 60, 60, 60, 17], [17, 60, 60, 60, 60, 60, 60, 60, 17], [17, 9, 9, 9, 9, 9, 9, 9, 17], [17, 60, 60, 60, 60, 60, 60, 60, 17], [17, 60, 60, 60, 60, 60, 60, 60, 17], [17, 17, 17, 17, 17, 17, 17, 17, 17]], [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 59, 59, 59, 59, 59, 59, 59, 0], [0, 59, 59, 59, 59, 59, 59, 59, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 141, 141, 141, 141, 141, 141, 141, 0], [0, 141, 141, 141, 141, 141, 141, 141, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]] e.root_tag['Data'] = TAG_Byte_Array([[[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 7, 0, 7, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 7, 0, 7, 0, 7, 0], [0, 0, 0, 0, 7, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]], [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 7, 6, 6, 3, 2, 2, 2, 0], [0, 6, 2, 6, 3, 5, 4, 6, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 6, 4, 3, 5, 2, 5, 0], [0, 5, 5, 7, 5, 7, 5, 6, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]]) return e
def sticksCluster(level,box,R): op = "sticksCluster" #level2 = level.extractSchematic(box) # Working set level2 = MCSchematic((box.width,box.height,box.length)) box2 = BoundingBox((0,0,0),(box.width,box.height,box.length)) smoothamount = 1 LIM = 8 ox = box.minx oy = box.miny oz = box.minz w = box.width h = box.height d = box.length PSet = [] numClusters = R.randint(1,5)*2+1 for i in xrange(0,numClusters): print i (x,y,z) = (box.minx+(R.randint(0,w)>>1)+(w>>2),box.miny+(R.randint(0,h)>>1)+(h>>2),box.minz+(R.randint(0,d)>>1)+(d>>2)) for k in xrange(0,R.randint(3,5)*2+1): (x1,y1,z1) = pointRandomByDistanceVRange(R,(w+h+d)>>3,w,h,d,0.1) numRays = R.randint(1,5)*2+1 for j in xrange(0,numRays): PSet.append(makePathUnique(calcLinesSmooth1(smoothamount,[(x,y,z),(x+x1+R.randint(-LIM,LIM),y+y1+R.randint(-LIM,LIM),z+z1+R.randint(-LIM,LIM))]))) #print PSet for PLine in PSet: for (x1,y1,z1) in PLine: setBlock(level2,getBlock(level,x1,y1,z1),x1-box.minx,y1-box.miny,z1-box.minz) level.copyBlocksFrom(level2, box2, (box.minx, box.miny, box.minz ))
def mesh2D(level,box,spacing): op = "mesh2D" #level2 = level.extractSchematic(box) # Working set level2 = MCSchematic((box.width,box.height,box.length)) box2 = BoundingBox((0,0,0),(box.width,box.height,box.length)) smoothamount = 1 ox = box.minx oy = box.miny oz = box.minz w = box.width h = box.height d = box.length PSet = [] x,z = ox,oz while x < box.maxx: while z < box.maxz: y = box.maxy-1 while y >= box.miny: block = getBlock(level,x,y,z) if block != (0,0): PSet.append((block,x-box.minx,y-box.miny,z-box.minz)) y = box.miny y -= 1 z += spacing x += spacing for (b,x,y,z) in PSet: setBlock(level2,b,x,y,z) level.copyBlocksFrom(level2, box2, (box.minx, box.miny, box.minz ))
def houseOne(): e = MCSchematic(shape=(5, 5, 6), filename='') e._Blocks = [[[4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [0, 0, 67, 0, 0]], [[4, 5, 5, 5, 4], [5, 0, 0, 0, 5], [5, 0, 0, 0, 5], [5, 0, 0, 0, 5], [4, 5, 0, 5, 4], [0, 0, 0, 0, 0]], [[4, 5, 102, 5, 4], [5, 0, 0, 0, 5], [102, 0, 0, 0, 102], [5, 0, 0, 0, 5], [4, 5, 0, 5, 4], [0, 0, 0, 0, 0]], [[4, 5, 5, 5, 4], [5, 0, 0, 0, 5], [5, 0, 0, 0, 5], [5, 0, 50, 0, 5], [4, 5, 5, 5, 4], [0, 0, 0, 0, 0]], [[17, 17, 17, 17, 17], [17, 5, 5, 5, 17], [17, 5, 5, 5, 17], [17, 5, 5, 5, 17], [17, 17, 17, 17, 17], [0, 0, 0, 0, 0]]] e.root_tag['Data'] = TAG_Byte_Array([[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 3, 0, 0]], [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]], [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]], [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 4, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]], [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]]) return e
def __init__(self, char_set, screen_access_unit): """ :param char_set: Path to a char-set schematic :param memory_access_unit: we treat the screen as a memory. """ super(ScreenUnit, self).__init__(0) if not isinstance(char_set, MCSchematic): char_set = MCSchematic(filename=char_set) self.char_set = self.add_compound(char_set) # How many different characters this screen can printout. self.char_set_size = int(char_set.size[1]) # 2 dimensional area which is taken by a character. self.character_sprite_size = (int(char_set.size[0]), 1, int(char_set.size[2])) # This is the unit which will give us the way to navigate in the charecters. self.char_set_access_unit = self.add_unit( MemoryAccessUnit((1, self.char_set_size, 1), self.character_sprite_size, self.char_set)) assert self.char_set_access_unit.word_size == screen_access_unit.word_size, \ "char set word size must equal to the screen." self.screen_access_unit = self.add_unit(screen_access_unit) self.input_character = self.add_input( self.char_set_access_unit.input_address) self.input_location = self.add_input( self.screen_access_unit.input_address)
def retrieveSelectedSchematic( theFileName ): # Load a schematic, analyse it (find the bounds) and return the schematic and bounding box # ... todo: Cache schematics so I don't need to analyse on each access method = "retrieveSelectedSchematic" print 'Loading schematic from file - %s' % (theFileName) charSchematic = MCSchematic(shape=SHAPE, filename=theFileName) return (charSchematic, analyse(charSchematic))
def palms(level, box, R, smoothamount, matLeaf, matTrunk, matFruit, matGround, maxHeight, maxWidth, numAttempts, spacing): method = "palms" print str(time.ctime()) + " Starting " + method cx = (box.maxx + box.minx) >> 1 cy = (box.maxy + box.miny) >> 1 cz = (box.maxz + box.minz) >> 1 P = [(cx, cz)] iters = 0 keepGoing = True while keepGoing == True: x, z = P.pop() print x, z if x > box.maxx - maxWidth: x = box.minx + maxWidth + (x - (box.maxx - maxWidth)) if x < box.minx + maxWidth: x = box.maxx - maxWidth - (box.minx + maxWidth - x) if z > box.maxz - maxWidth: z = box.minz + maxWidth + (z - (box.maxz - maxWidth)) if z < box.minz + maxWidth: z = box.maxz - maxWidth - (box.minz + maxWidth - z) y = box.maxy - 1 while y >= box.miny: block = getBlock(level, x, y, z) if block == matGround: theHeight = maxHeight if theHeight > box.maxy - y: theHeight = box.maxy - y #theBox = BoundingBox((x-(maxWidth>>1),y,z-(maxWidth>>1)),(maxWidth,theHeight,maxWidth)) theBox = BoundingBox((0, 0, 0), (maxWidth, theHeight, maxWidth)) theLevel = MCSchematic((maxWidth, theHeight, maxWidth)) palm(theLevel, theBox, R, smoothamount, matLeaf, matTrunk, matFruit) b = range(4096) b.remove( 0 ) # @CodeWarrior0 and @Wout12345 explained how to merge schematics level.copyBlocksFrom(theLevel, theBox, ((x - (maxWidth >> 1), y, z - (maxWidth >> 1))), b) y = box.miny y = y - 1 dir = R.random() * pi * 2.0 P.append((x + spacing * cos(dir), z + spacing * sin(dir))) iters = iters + 1 if iters > numAttempts: #(box.maxx-box.minx)+(box.maxy-box.miny): keepGoing = False print str(time.ctime()) + " Ended " + method
def convertVOXFileToSchematic(level, box, file): print 'Convert ' + file (version, numModels, VOXchunks, matlist) = parseVOXFile(file) colours = getRGBA(VOXchunks) (w, h, d) = getSize(VOXchunks) print w, h, d schem = MCSchematic((w, d, h)) box1 = BoundingBox((0, 0, 0), (w, d, h)) renderModels(schem, box1, VOXchunks, matlist, colours) schem.saveToFile(file + ".schematic") print 'Converted ' + file
def Pressure(level, box, options): method = "Pressure" (method, (width, height, depth), (centreWidth, centreHeight, centreDepth)) = FuncStart(level, box, options, method) # Within the selection box, dislocate 'slabs' of material vertically / horizontally to simulate quake damage # Step 1 - define a fault line # Step 2 - for each side of the line, move the pieces apart r = Random() scratch = MCSchematic((width, height, depth)) box = BoundingBox((0, 0, 0), (width, height, depth)) Q = [] fractures = options["Fracture Planes"] print fractures epicentres = options["Epicentres"] quantum = options["Quantum"] for i in xrange(0, epicentres): epiX = centreWidth + randint(-int(centreWidth / 2), int( centreWidth / 2)) epiY = centreHeight + randint(-int(centreHeight / 2), int(centreHeight / 2)) epiZ = centreDepth + randint(-int(centreDepth / 2), int( centreDepth / 2)) for iter in xrange(0, fractures): slope = r.random() * pi * 2 # x/z angle of the fault line slant = r.random() * pi # vertical pitch of the fault line (planeX, planeY, planeZ) = (cos(slope) * sin(slant), cos(slant), sin(slope) * sin(slant)) denom = (planeX * planeX + planeY * planeY + planeZ * planeZ) max = randint(1, options["Scale"]) (shiftX1, shiftY1, shiftZ1) = (-cos(slope) * sin(slant) * quantum, -cos(slant) * quantum, -sin(slope) * sin(slant) * quantum) (shiftX2, shiftY2, shiftZ2) = (cos(slope) * sin(slant) * quantum, cos(slant) * quantum, sin(slope) * sin(slant) * quantum) Q.append( ((planeX, planeY, planeZ, denom, epiX, epiY, epiZ), (shiftX1, shiftY1, shiftZ1), (shiftX2, shiftY2, shiftZ2))) RenderShatteredLandUnderPressure(level, scratch, Q, width, height, depth) if options["Show Planes?"] == True: RenderPlanes(level, scratch, Q, width, height, depth) # Copy result from working set #b=range(4096); b.remove(0) # @CodeWarrior0 and @Wout12345 explained how to merge schematics level.copyBlocksFrom(scratch, box, (0, 0, 0)) FuncEnd(level, box, options, method)
def Bands(level,box,spacing): op = "Bands" #level2 = level.extractSchematic(box) # Working set level2 = MCSchematic((box.width,box.height,box.length)) box2 = BoundingBox((0,0,0),(box.width,box.height,box.length)) airlevel = MCSchematic((box.width,box.height,box.length)) airbox = BoundingBox((0,0,0),(box.width,box.height,box.length)) x = box.minx while x < box.maxx: if x%10 == 0: print str(time.ctime())+" Running X "+op+" "+str(x) for z in xrange(box.minz,box.maxz): for y in xrange(box.miny,box.maxy): if getBlock(level,x,y,z) != (0,0): # This is a surface setBlock(level2,getBlock(level,x,y,z),x-box.minx,y-box.miny,z-box.minz) x += spacing y = box.miny while y < box.maxy: if y%10 == 0: print str(time.ctime())+" Running Y "+op+" "+str(x) for z in xrange(box.minz,box.maxz): for x in xrange(box.minx,box.maxx): if getBlock(level,x,y,z) != (0,0): # This is a surface setBlock(level2,getBlock(level,x,y,z),x-box.minx,y-box.miny,z-box.minz) y += spacing z = box.minz while z < box.maxz: if z%10 == 0: print str(time.ctime())+" Running Z "+op+" "+str(x) for y in xrange(box.miny,box.maxy): for x in xrange(box.minx,box.maxx): if getBlock(level,x,y,z) != (0,0): # This is a surface setBlock(level2,getBlock(level,x,y,z),x-box.minx,y-box.miny,z-box.minz) z += spacing level.copyBlocksFrom(level2, box2, (box.minx, box.miny, box.minz ))
def loadSchematicsFromDirectory(pathname): print "Loading in schematics from directory", pathname SchematicFileNames = glob.glob(join(pathname, "*.schematic")) for fileName in SchematicFileNames: print fileName print "Found", len(SchematicFileNames), "schematic files" # End cached file names CACHE = [] for fn in SchematicFileNames: print "Loading schematic from file", fn sourceSchematic = MCSchematic(filename=fn) CACHE.append((sourceSchematic, fn)) return CACHE
def readAssets(path): print 'Scanning available schematics...' SchematicFileNames = glob.glob(path + "/*.schematic") for fileName in SchematicFileNames: print fileName print 'Found %s schematic files' % (len(SchematicFileNames)) # End cached file names CACHE = [] for fn in SchematicFileNames: print 'Loading schematic from file - %s' % (fn) sourceSchematic = MCSchematic(filename=fn) # (x,y,z) = sourceSchematic.size CACHE.append(sourceSchematic) return CACHE
def perform(level, box, options): schematic = MCSchematic( (width, height, length), mats=level.materials ) # Create a schematic of width, height and length. # One thing to note is that the schematic is based around 0, 0, 0 so the next two should take this into account schematic.setBlockAt( x, y, z, block ) # These are the same as usual but you are doing it with the schematic rather than the level schematic.setBlockDataAt(x, y, z, data) schematic.TileEntities.append( tileent) # Again the same but with the schematic rather than the level schematic.Entities.append(ent) # see 3) and 5) respectively editor.addCopiedSchematic( schematic ) # This adds the schematic you put together to the clipboard to be coppied back in by the user
def Lattice(level,box,spacing): op = "Lattice" #level2 = level.extractSchematic(box) # Working set level2 = MCSchematic((box.width,box.height,box.length)) box2 = BoundingBox((0,0,0),(box.width,box.height,box.length)) for x in xrange(box.minx,box.maxx): if x%10 == 0: print str(time.ctime())+" Running "+op+" "+str(x) for z in xrange(box.minz,box.maxz): for y in xrange(box.miny,box.maxy): if ((x%spacing == 0 and z%spacing == 0 and y%spacing == 0) or (x%spacing != 0 and z%spacing == 0 and y%spacing == 0) or (x%spacing == 0 and z%spacing != 0 and y%spacing == 0) or (x%spacing == 0 and z%spacing == 0 and y%spacing != 0) ): setBlock(level2,getBlock(level,x,y,z),x-box.minx,y-box.miny,z-box.minz) level.copyBlocksFrom(level2, box2, (box.minx, box.miny, box.minz ))
def MedievalWallSection(box, options, fillMaterial, edgeMaterial, glassMaterial): method = "MedievalWallSection" level = MCSchematic((box.maxx - box.minx, box.maxy - box.miny, box.maxz - box.minz)) # Working object (method, (width, height, depth), (centreWidth, centreHeight, centreDepth)) = FuncStart(level, box, "", method) # Log # Wall drawRectangle(level, box, options, (box.minx, box.miny, box.minz + 1), (box.maxx - 1, box.miny, box.minz + 1), (box.maxx - 1, box.maxy - 1, box.minz + 1), (box.minx, box.maxy - 1, box.minz + 1), fillMaterial) # Edge around wall drawLine(level, edgeMaterial, (box.minx, box.miny, box.minz + 1), (box.maxx - 1, box.miny, box.minz + 1)) drawLine(level, edgeMaterial, (box.maxx - 1, box.miny, box.minz + 1), (box.maxx - 1, box.maxy - 1, box.minz + 1)) drawLine(level, edgeMaterial, (box.maxx - 1, box.maxy - 1, box.minz + 1), (box.minx, box.maxy - 1, box.minz + 1)) drawLine(level, edgeMaterial, (box.minx, box.maxy - 1, box.minz + 1), (box.minx, box.miny, box.minz + 1)) # Edge proper drawLine(level, edgeMaterial, (box.minx, box.miny, box.minz), (box.maxx - 1, box.miny, box.minz)) drawLine(level, edgeMaterial, (box.maxx - 1, box.miny, box.minz), (box.maxx - 1, box.maxy - 1, box.minz)) drawLine(level, edgeMaterial, (box.maxx - 1, box.maxy - 1, box.minz), (box.minx, box.maxy - 1, box.minz)) drawLine(level, edgeMaterial, (box.minx, box.maxy - 1, box.minz), (box.minx, box.miny, box.minz)) # Braces drawLine(level, edgeMaterial, (box.minx, box.miny, box.minz), (box.maxx - 1, box.maxy - 1, box.minz)) drawLine(level, edgeMaterial, (box.minx, box.maxy - 1, box.minz), (box.maxx - 1, box.miny, box.minz)) return level
def placeASchematic(x, y, z, theFileName, level, box, options): # CONSTANTS AND GLOBAL VARIABLES method = "placeASchematic" print '%s: Started at %s' % (method, time.ctime()) (width, height, depth) = getBoxSize(box) centreWidth = width / 2 centreHeight = height / 2 centreDepth = depth / 2 SHAPE = (32, 32, 32) # END CONSTANTS # cursorPosn = box.origin # import the corresponding MCSchematic to the supplied filename print 'Loading schematic from file - %s' % (theFileName) charSchematic = MCSchematic(shape=SHAPE, filename=theFileName) cursorPosn = (x, y, z) bb = analyse(charSchematic) level.copyBlocksFrom(charSchematic, bb, cursorPosn) print '%s: Ended at %s' % (method, time.ctime())
def facadeSection(materials,size,windowsize): ''' Builds a building wall section wwwwwwwwwwww <-- Roofline / crenelation ########____ ## ## ##____ ## ## ##___o ########__o ## ## ##_o ## ## ##_o ########_o__ ^^^^^^^ ^^^^ windows central ''' width, height, depth = size model = MCSchematic(shape=size) PreferredWidth,PreferredHeight = windowsize centralSectionWidth = width>>3 # 1/8th # windowsBox = BoundingBox((0,0,0),((width>>1)-centralSectionWidth,height,depth)) # centralBox = BoundingBox((0,0,0),(centralSectionWidth,height,depth)) # A window # Windows WINDOW = window((PreferredWidth,PreferredHeight,depth),materials) tileWindow(model,WINDOW) crenelationDepth = depth crenelationHeight = randint(1,crenelationDepth) crenelation(model,materials,(crenelationDepth,crenelationHeight)) return model
def mineText(level, box, options): # CONSTANTS AND GLOBAL VARIABLES method = "MINETEXT" print '%s: Started at %s' % (method, time.ctime()) (width, height, depth) = getBoxSize(box) centreWidth = width / 2 centreHeight = height / 2 centreDepth = depth / 2 scratchpad = level.extractSchematic(box) message = options["Message:"] spacing = options["Spacing:"] font = options["Font:"] SHAPE = (30, 30, 30) # END CONSTANTS print os.getcwd() cursorPosn = box.origin # for each character in the message, import the corresponding MCSchematic into the selection box. for C in list(message): theFileName = "filters/font/" + font + "/" if C.isupper() == True: theFileName = theFileName + "upper/" theFileName = theFileName + C + ".schematic" print 'Loading character from file - %s' % (theFileName) charSchematic = MCSchematic(shape=SHAPE, filename=theFileName) bb = analyse(charSchematic) level.copyBlocksFrom(charSchematic, bb, cursorPosn) # level.copyBlocksFrom(charSchematic, BoundingBox((0, 0, 0), SHAPE), cursorPosn) (x, y, z) = cursorPosn if width >= depth: x = x + charSchematic.Width + spacing else: z = z + charSchematic.Length + spacing cursorPosn = (x, y, z) print '%s: Ended at %s' % (method, time.ctime())
def ahouse(level0,box0,options): # Init and log method = "AHouse" (method, (width, height, depth), (centreWidth, centreHeight, centreDepth)) = FuncStart(level0,box0,options,method) # Log start level = MCSchematic((width,height,depth)) box = BoundingBox((0,0,0),(width,height,depth)) # A house has a number of levels and an interior and exterior. There is a roof. # The exterior has windows, doors, balconies, planter boxes, signs, banners, etc. Materials may differ by level # The roof may be of various block type construction and is typically pitched. A chimney appears! # Even where the face of the house is sloping # Random seeded generators RAND = getRandFromSeed(options) RANDMAT = getRandFromSeed(options) # House geometry/structure FLOORHEIGHT = RAND.randint(4,8) NUMFLOORS = int(height/FLOORHEIGHT) ROOFLEVELS = RAND.randint(0,(NUMFLOORS-3)%NUMFLOORS)+2 # How many levels are devoted to the roofline. RECESS = 1 # RAND.randint(1,2) # Pallette MAT_WALL_EXT = [ (35,0), (35,8),(172,0), (45,0), (82,0), (43,9), (5,2), (5,1)] MAT_WALL_EXT2 = [ (35,0), (35,8),(172,0), (45,0), (82,0), (43,9), (5,2), (5,1)] MAT_WALL_BEAM = [ (5,5), (5,3),(17,12),(17,13),(17,15), (162,12),(162,13) ] MAT_WINDOW = [ (160,8), (160,0), (160,7), (95,8), (95,0) ] MAT_FLOOR = [ (5,0), (5,2), (5,3)] MAT_DOOR = [ (193,1), (193,3) ] # Choose material palette mWall = chooseMaterial(MAT_WALL_EXT,RANDMAT) mWallBeam = chooseMaterial(MAT_WALL_BEAM,RANDMAT) mFloor = chooseMaterial(MAT_FLOOR,RANDMAT) mWindow = chooseMaterial(MAT_WINDOW,RANDMAT) mDoor = chooseMaterial(MAT_DOOR,RANDMAT) oWall = mWall chopped = True # I have to hand the house geometry into the child procedures for consistency for i in xrange(0,NUMFLOORS): roomBox = BoundingBox((box.minx+RECESS,box.miny+i*FLOORHEIGHT,box.minz+RECESS),(width-2*RECESS,FLOORHEIGHT,depth-2*RECESS)) if i == 0: # Ground floor if RAND.randint(1,100) >80: # Cobblestone mWall = (4,0) roomBox = BoundingBox((box.minx+int(RECESS*1.5),box.miny+i*FLOORHEIGHT,box.minz+int(RECESS*1.5)),(width-2*int(RECESS*1.5),FLOORHEIGHT,depth-2*int(RECESS*1.5))) mWall = oWall if i == 1: # First floor if RAND.randint(1,100) > 70: # Randomise wall material? mWall = chooseMaterial(MAT_WALL_EXT,RANDMAT) if RAND.randint(1,100) > 50: chopped = False if i == 0 and RAND.randint(1,100) > 50: # Special collection of rooms instead of one room only for j in xrange(0,RAND.randint(2,5)): px = RAND.randint(RECESS,RECESS+int(centreWidth)) pz = RAND.randint(RECESS,RECESS+int(centreDepth)) pxd = width-RECESS-px pzd = depth-RECESS-pz roomBox = BoundingBox((box.minx+px,box.miny+i*FLOORHEIGHT,box.minz+pz), (RAND.randint(int(pxd/2),pxd),FLOORHEIGHT,RAND.randint(int(pzd/2),pzd))) room(level,roomBox,options,RAND,getRandFromSeed(options),mWall,mWallBeam,mFloor,mWindow,mDoor,chopped) doors(level,roomBox,options,RAND,mDoor) # Struts for y in xrange(box.miny+i*FLOORHEIGHT,box.miny+(i+1)*FLOORHEIGHT): setBlockForced(level,mWallBeam,box.minx+2,y,box.minz+2) setBlockForced(level,mWallBeam,box.maxx-3,y,box.maxz-3) setBlockForced(level,mWallBeam,box.minx+2,y,box.maxz-3) setBlockForced(level,mWallBeam,box.maxx-3,y,box.minz+2) else: # One box only room(level,roomBox,options,RAND,getRandFromSeed(options),mWall,mWallBeam,mFloor,mWindow,mDoor,chopped) if i == 0: doors(level,roomBox,options,RAND,mDoor) stairs(level,box,options,RAND,RANDMAT) # Detail # -- Door detail placePorch(level,box,options,RAND,RANDMAT,mDoor) # -- Windows placeWindows(level,box,options,RAND,RANDMAT,FLOORHEIGHT,mWindow,mWall,mWallBeam,mDoor) # Roof(s) - size and shape can be tuned through parameters. Some extreme A-frame high fantasy roofs can occur in the initial version of this generator roofMaterial = RANDMAT.randint(0,10) if depth > width: roofNS(level,box,options,RAND,RANDMAT,height-ROOFLEVELS*FLOORHEIGHT,roofMaterial,mWall) if RAND.randint(1,100) > 50: roofEW(level,box,options,RAND,RANDMAT,height-ROOFLEVELS*FLOORHEIGHT,roofMaterial,mWall) else: roofEW(level,box,options,RAND,RANDMAT,height-ROOFLEVELS*FLOORHEIGHT,roofMaterial,mWall) if RAND.randint(1,100) > 50: roofNS(level,box,options,RAND,RANDMAT,height-ROOFLEVELS*FLOORHEIGHT,roofMaterial,mWall) if RAND.randint(1,100) > 5: chimney(level,box,options,RAND,(RAND.randint(box.minx+1,box.maxx-2),box.miny,RAND.randint(box.minz+1,box.maxz-2))) b=range(4096) b.remove(0) # @CodeWarrior0 and @Wout12345 explained how to merge schematics level0.copyBlocksFrom(level, box, (box0.minx, box0.miny, box0.minz ),b) level0.markDirtyBox(box0) # End / log FuncEnd(level,box,options,method)
def perform(level, box, options): # Traverse all the non-air blocks connected to the selected block at the origin of the box. AIR = 0 STONE = 1 SIZE = 127 WORKING = MCSchematic((2*SIZE,2*SIZE,2*SIZE)) DIAGONAL = options["Include diagonals?"] trackx = SIZE tracky = SIZE trackz = SIZE minx = box.minx miny = box.miny minz = box.minz maxx = box.maxx-1 maxy = box.maxy-1 maxz = box.maxz-1 count = 0 Q = [] Q.append( (box.minx, box.miny, box.minz) ) while len(Q) > 0: print '%s %s %s %s %s %s' % (minx,miny,minz,maxx,maxy,maxz) (x, y, z) = Q.pop() print '%s %s %s Popped' % (x,y,z) tx = trackx+x-box.minx ty = tracky+y-box.miny tz = trackz+z-box.minz if level.blockAt(x, y, z) != AIR and WORKING.blockAt(tx,ty,tz) == AIR: WORKING.setBlockAt(int(tx), int(ty), int(tz), STONE) print '%s %s %s = %s' % (x,y,z,level.blockAt(x, y, z)) if x < minx: minx = x if y < miny: miny = y if z < minz: minz = z if x > maxx: maxx = x if y > maxy: maxy = y if z > maxz: maxz = z Q.append( (x-1, y, z) ) Q.append( (x+1, y, z) ) Q.append( (x, y-1, z) ) Q.append( (x, y+1, z) ) Q.append( (x, y, z-1) ) Q.append( (x, y, z+1) ) # Sancarn (https://www.youtube.com/user/Sancarn) says diagonals are useful for redstone circuits if DIAGONAL == True: Q.append( (x, y-1, z-1) ) Q.append( (x-1, y, z-1) ) Q.append( (x-1, y-1, z) ) Q.append( (x, y+1, z+1) ) Q.append( (x+1, y, z+1) ) Q.append( (x+1, y+1, z) ) Q.append( (x, y+1, z-1) ) Q.append( (x+1, y, z-1) ) Q.append( (x+1, y-1, z) ) Q.append( (x, y-1, z+1) ) Q.append( (x-1, y, z+1) ) Q.append( (x-1, y+1, z) ) Q.append( (x-1, y-1, z-1) ) Q.append( (x-1, y-1, z+1) ) Q.append( (x-1, y+1, z-1) ) Q.append( (x-1, y+1, z+1) ) Q.append( (x+1, y-1, z-1) ) Q.append( (x+1, y-1, z+1) ) Q.append( (x+1, y+1, z-1) ) Q.append( (x+1, y+1, z+1) ) count = count+1 if count%1 == 10000: print '%s' % (len(Q)) editor = inspect.stack()[1][0].f_locals.get('self', None).editor # Texelelf newBox = BoundingBox( (minx,miny,minz), (maxx-minx+1,maxy-miny+1,maxz-minz+1)) editor.selectionTool.setSelection(newBox) # Texelelf editor.mainViewport.cameraPosition = (newBox.size/2)+newBox.origin # Texelelf
def Expand(level, box, options): # I pulled the connected-block scan code from my SELECTOR filter method = "Expand" (method, (width, height, depth), (centreWidth, centreHeight, centreDepth)) = FuncStart(level, box, options, method) AIR = (0, 0) DIAGONAL = True #GAP = options["Scale"] # Save - because I am a destructive beast SAVED = level.extractSchematic( box) # Best I can do is save the selection and restore it later # Scan through the selection box. Find all the connected blocks of the same type and create new schematics with only those blocks. # Find the largest dimension. We need it for a scratchpad to track progress. SIZE = width if depth > SIZE: SIZE = depth if height > SIZE: SIZE = height trackx = SIZE # Centre of the tracking schematic tracky = SIZE trackz = SIZE Components = [] print 'Looking for connected sets of blocks...' for iterY in xrange(0, height): for iterZ in xrange(0, depth): for iterX in xrange(0, width): (matBlock, matID) = getBlock(level, box.minx + iterX, box.miny + iterY, box.minz + iterZ) if ( matBlock, matID ) != AIR: # Something to work with, scan the surroundings for connected blocks of the same type, and if found then build out a connected graph of blocks print 'Connecting blocks from %s %s %s' % (iterX, iterY, iterZ) # Find all of the connected blocks WORKING = MCSchematic( (2 * SIZE, 2 * SIZE, 2 * SIZE )) # temp - track progress finding connected blocks. minx = width - 1 # Track extremities, we'll blit out these blocks later. miny = height - 1 minz = depth - 1 maxx = 0 maxy = 0 maxz = 0 Q = [] Q.append((iterX, iterY, iterZ)) numBlocks = 0 (px, py, pz) = (0, 0, 0) while len(Q) > 0: (x, y, z) = Q.pop() print 'Checking block %s %s %s for Block %s' % ( x, y, z, matBlock) tx = trackx + x ty = tracky + y tz = trackz + z ((block, ID), NBT) = getBlockWithNBT(level, box.minx + x, box.miny + y, box.minz + z) #(block,ID) = getBlock(level,box.minx+x,box.miny+y,box.minz+z) # print '...found Block %s' % (block) if block == matBlock: # print 'Block %s matches %s at %s %s %s' % (block, matBlock, x,y,z) if getBlock(WORKING, tx, ty, tz) == AIR: numBlocks += 1 setBlockWithNBT( WORKING, (matBlock, matID), NBT, int(tx), int(ty), int(tz)) # Mark this block as 'traversed' #setBlock(WORKING, (matBlock,matID), int(tx), int(ty), int(tz)) # Mark this block as 'traversed' setBlock(level, AIR, box.minx + x, box.miny + y, box.minz + z) # erase the source block (px, py, pz) = (px + tx, py + ty, pz + tz) if x < minx: minx = x if y < miny: miny = y if z < minz: minz = z if x > maxx: maxx = x if y > maxy: maxy = y if z > maxz: maxz = z Q.append((x - 1, y, z)) Q.append((x + 1, y, z)) Q.append((x, y - 1, z)) Q.append((x, y + 1, z)) Q.append((x, y, z - 1)) Q.append((x, y, z + 1)) if DIAGONAL == True: Q.append((x, y - 1, z - 1)) Q.append((x - 1, y, z - 1)) Q.append((x - 1, y - 1, z)) Q.append((x, y + 1, z + 1)) Q.append((x + 1, y, z + 1)) Q.append((x + 1, y + 1, z)) Q.append((x, y + 1, z - 1)) Q.append((x + 1, y, z - 1)) Q.append((x + 1, y - 1, z)) Q.append((x, y - 1, z + 1)) Q.append((x - 1, y, z + 1)) Q.append((x - 1, y + 1, z)) Q.append((x - 1, y - 1, z - 1)) Q.append((x - 1, y - 1, z + 1)) Q.append((x - 1, y + 1, z - 1)) Q.append((x - 1, y + 1, z + 1)) Q.append((x + 1, y - 1, z - 1)) Q.append((x + 1, y - 1, z + 1)) Q.append((x + 1, y + 1, z - 1)) Q.append((x + 1, y + 1, z + 1)) # Finished scanning - I now have a set of the connected blocks. Blit it out into a new schematic and store it in a queue snipBox = BoundingBox( (SIZE + minx, SIZE + miny, SIZE + minz), (SIZE + maxx + 1, SIZE + maxy + 1, SIZE + maxz + 1)) snipSchematic = WORKING.extractSchematic(snipBox) Components.append( (snipSchematic, BoundingBox((0, 0, 0), (maxx - minx + 1, maxy - miny + 1, maxz - minz + 1)), (maxx - minx + 1, maxy - miny + 1, maxz - minz + 1), miny, numBlocks, (px / numBlocks, py / numBlocks, pz / numBlocks))) print 'Drawing components I found...' # Now I have a set of Components. Where to draw them? b = range(4096) b.remove( 0) # @CodeWarrior0 and @Wout12345 explained how to merge schematics startX = width startY = height distance = SIZE angle = pi ANGLES = options["Angles"] for (P, bx, (w, h, d), y, blockCount, (comx, comy, comz)) in Components: if blockCount >= options["Blocks"]: # Only plot objects above this size #startX += GAP #startY += GAP #distance = sqrt(comx*comx + comz*comz + comy*comy) #+randint(10,50) #print 'Component %s %s %s Centre of Mass %s %s %s, %s' % (P,bx,w,comx,comy,comz,distance) #horizangle = atan2(comz,comx) #(newposx,newposz) = (distance*cos(horizangle),distance*sin(horizangle)) (newposx, newposz) = (distance * cos(angle), distance * sin(angle)) level.copyBlocksFrom(P, bx, (box.minx + int(newposx), box.miny + y, box.minz + int(newposz)), b) #print 'Copied component to %s %s %s' % (box.minx+startX, box.miny, box.minz ) #startX += w #startY += h angle += 2 * pi / ANGLES distance += SIZE / ANGLES level.copyBlocksFrom(SAVED, BoundingBox((0, 0, 0), (width, height, depth)), (box.minx, box.miny, box.minz), b) FuncEnd(level, box, options, method) # Log end
def makeBlankAreaOfSizeWHD(width, height, depth): return MCSchematic((width, height, depth))
def window(dim,materials): ''' Create a window design of the specified size ''' model = MCSchematic(shape=dim) # This will be returned. A model of a window width and height-wise with depth features (x,y,z) = dim depth = z width = x height = y heightHalf = y>>1 heightQtr = heightHalf>>1 # Design half the window and mirror it width-wise widthHalf = x>>1 if widthHalf<<1 < width: widthHalf += 1 # If the width is odd then there is a centre position that needs to be drawn otherwise there would be a gap shapeWindowHalf = MCSchematic(shape=(widthHalf,height,depth)) shapeFill(shapeWindowHalf,materials[0],(0,0,0),(widthHalf-1,height-1,0)) # A window is glass in the centre, Stone with vertical design elements outside that, and window sill and top GLASSTOP = randint(heightQtr,heightHalf) # Distances from the centre GLASSBOT = randint(heightQtr,heightHalf) GLASSEDGE = (width>>1)-1 #randint(width>>2,(width>>1)) if GLASSEDGE >= (width>>1)-1: GLASSEDGE -= 2 if GLASSEDGE < 1: GLASSEDGE = 2 if GLASSTOP >= heightHalf-1: GLASSTOP -= 2 # print GLASSEDGE,shapeWindowHalf # Glass shapeFill(shapeWindowHalf,materials[1%len(materials)],(0,GLASSBOT,0),(GLASSEDGE,heightHalf+GLASSTOP,0)) # Horizontals for y in xrange(0,heightHalf-GLASSBOT): depthhere = randint(0,depth) for z in xrange(1,depthhere): shapeFill(shapeWindowHalf,materials[3%len(materials)],(0,y,z),(widthHalf,y,z)) for y in xrange(heightHalf+GLASSTOP,height): depthhere = randint(0,depth) for z in xrange(1,depthhere): shapeFill(shapeWindowHalf,materials[3%len(materials)],(0,y,z),(widthHalf,y,z)) # Verticals for x in xrange(GLASSEDGE,width): depthhere = randint(0,depth) if x%width-1 == 0: depthhere = randint(1,depth) if depthhere > 0: shapeFill(shapeWindowHalf,materials[2%len(materials)],(x,0,0),(x,height-1,depthhere)) # Render b=range(4096) b.remove(0) # @CodeWarrior0 and @Wout12345 explained how to merge schematics model.copyBlocksFrom(shapeWindowHalf, BoundingBox((0,0,0),(widthHalf,height,depth)), (widthHalf-(width%2),0,0),b) # cloneSchematic(model,shapeWindowHalf,(0,0,0)) #describe(model) shapeWindowHalf.flipNorthSouth() model.copyBlocksFrom(shapeWindowHalf, BoundingBox((0,0,0),(widthHalf,height,depth)), (0,0,0),b) return model
def building(originalLevel, originalBox, options): b=range(4096) b.remove(0) # @CodeWarrior0 and @Wout12345 explained how to merge schematics level = originalLevel.extractSchematic(originalBox) # Working set width = originalBox.width height = originalBox.height depth = originalBox.length box = BoundingBox((0,0,0),(width,height,depth)) materials = [getBlockFromOptions(options,"WALL:"), getBlockFromOptions(options,"GLASS:"), getBlockFromOptions(options,"FACADE VERTICAL:"), getBlockFromOptions(options,"FACADE HORIZONTAL:"), ] # Ground Floor # Windows - need to be consistent Fwidth = Factorise(width>>1) PreferredWidth = Fwidth[randint(0,(len(Fwidth)-1)>>2)] if PreferredWidth < 6: PreferredWidth = 6 if PreferredWidth > 12: PreferredWidth = 12 Fheight = Factorise(height) PreferredHeight = Fheight[randint(0,(len(Fheight)-1)>>2)] if PreferredHeight < 8: PreferredHeight = 8 # Face of the building facadePart = 1 facadeHeightCursor = 0 facadeDepthCursor = 0 scale = randint(1,5) originalFacadeDepth = 0 while facadeHeightCursor < height: # Build the face of the building facadeHeight = (1+(facadePart-1)*scale)*randint(8,32) # How tall should this bit be? if facadeHeightCursor+facadeHeight >= height: facadeHeight = height-facadeHeightCursor # Truncate the top section to the box height print facadeHeight,facadeHeightCursor facadeDepth = randint(2,4) if facadeDepth > depth: facadeDepth = depth if facadePart == 1: originalFacadeDepth = facadeDepth FACADE = facadeSection(materials,(width-(facadeDepth<<1)-facadeDepthCursor,facadeHeight,facadeDepth),(PreferredWidth,facadeHeight-2)) else: FACADE = facadeSection(materials,(width-(facadeDepth<<1)-facadeDepthCursor,facadeHeight,facadeDepth),(PreferredWidth,PreferredHeight)) # print FACADE, level, facadeDepthCursor print facadeHeight,facadeHeightCursor, FACADE level.copyBlocksFrom(FACADE, BoundingBox((0,0,0),(FACADE.Width,FACADE.Height-1,FACADE.Length)), (box.minx+facadeDepth+facadeDepthCursor,box.miny+facadeHeightCursor,box.maxz-1-facadeDepthCursor-facadeDepth)) print facadeHeight,facadeHeightCursor, FACADE, level facadeDepthCursor += 1 #facadeDepth facadePart +=1 facadeHeightCursor += facadeHeight # Verticals if randint(1,100) > 60: # Verticals all the way up for x in xrange(facadeDepthCursor,width>>1): depthhere = randint(0,depth) if x%PreferredWidth == 0: for z in xrange(1,depthhere): shapeFill(level,materials[2%len(materials)],(x,0,level.Length-facadeDepthCursor-1),(x,height,level.Length-1)) shapeFill(level,materials[2%len(materials)],(width-1-x,0,level.Length-facadeDepthCursor-1),(width-1-x,height,level.Length-1-facadeDepthCursor+depthhere)) FACADE = level.extractSchematic(BoundingBox((0,0,box.maxz-1-facadeDepthCursor-originalFacadeDepth),(box.maxx,box.maxy,box.maxz-(box.maxz-1-facadeDepthCursor-originalFacadeDepth)))) FACADE.flipEastWest() level.copyBlocksFrom(FACADE, BoundingBox((0,0,0),(FACADE.Width,FACADE.Height,FACADE.Length)), (box.minx, box.miny, box.minz),b) FACADE = level.extractSchematic(BoundingBox((0,0,0),(box.maxx,box.maxy,box.maxz))) FACADE.rotateLeft() level.copyBlocksFrom(FACADE, BoundingBox((0,0,0),(FACADE.Width,FACADE.Height,FACADE.Length)), (box.minx, box.miny, box.minz),b) shapeFill(level,materials[0%len(materials)],(0,0,0),(level.Width-1,0,level.Length-1)) # Ground floor p1 = (box.minx+facadeDepthCursor+originalFacadeDepth,height-5,box.minz+facadeDepthCursor+originalFacadeDepth) p2 = (width-1-1*(facadeDepthCursor+originalFacadeDepth),height-3,depth-1-1*(facadeDepthCursor+originalFacadeDepth)) # print p1,p2, facadeHeightCursor,height,level shapeFill(level,materials[0%len(materials)],p1,p2) # Roof buttressHeight = randint(height>>1,height) buttress = MCSchematic(shape=(facadeDepthCursor+originalFacadeDepth+1,buttressHeight,facadeDepthCursor+originalFacadeDepth+1)) shapeFill(buttress,materials[2%len(materials)],(0,0,0),(buttress.Width,buttress.Height,buttress.Length)) level.copyBlocksFrom(buttress, BoundingBox((0,0,0),(buttress.Width,buttress.Height,buttress.Length)),(0,0,0)) level.copyBlocksFrom(buttress, BoundingBox((0,0,0),(buttress.Width,buttress.Height,buttress.Length)),(level.Width-1-buttress.Width,0,0)) level.copyBlocksFrom(buttress, BoundingBox((0,0,0),(buttress.Width,buttress.Height,buttress.Length)),(level.Width-1-buttress.Width,0,level.Length-1-buttress.Length)) level.copyBlocksFrom(buttress, BoundingBox((0,0,0),(buttress.Width,buttress.Height,buttress.Length)),(0,0,level.Length-1-buttress.Length)) originalLevel.copyBlocksFrom(level, box, (originalBox.minx, originalBox.miny, originalBox.minz ),b)
def perform(level, box, options): for (chunk, slices, point) in level.getChunkSlices(box): if options["Include blocks"] == True: for t in chunk.TileEntities: x = t["x"].value y = t["y"].value z = t["z"].value if (x,y,z) in box: if options["LastOutput"] == True: if "LastOutput" in t: del t["LastOutput"] if options["Include entities"] == True: for e in chunk.Entities: x = e["Pos"][0].value y = e["Pos"][1].value z = e["Pos"][2].value if (x,y,z) in box: if options["LastOutput"] == True and "LastOutput" in e: del e["LastOutput"] if options["UUID"] == True: if "UUIDMost" in e: del e["UUIDMost"] if "UUIDLeast" in e: del e["UUIDLeast"] if options["AbsorptionAmount"] == True: if "AbsorptionAmount" in e: del e["AbsorptionAmount"] if options["Air"] == True: if "Air" in e: del e["Air"] if options["Attributes"] == True: if "Attributes" in e: del e["Attributes"] if options["DeathTime"] == True: if "DeathTime" in e: del e["DeathTime"] if options["Dimension"] == True: if "Dimension" in e: del e["Dimension"] if options["Fire"] == True: if "Fire" in e: del e["Fire"] if options["HurtByTimestamp"] == True: if "HurtByTimestamp" in e: del e["HurtByTimestamp"] if options["PortalCooldown"] == True: if "PortalCooldown" in e: del e["PortalCooldown"] #Getting inputs includeAir = options["Include air"] includeBlocks = options["Include blocks"] cmdBlockHeight = options["command block height (relative only)"] relativePos = options["Relative position"] cmdBlockPosing = options["Command block positioning"] editor = inspect.stack()[1][0].f_locals.get('self', None).editor commandlist = [] bracketsToClosetemp = 0 popOffBlocks = [6,8,9,10,11,12,13,27,28,31,32,36,37,38,39,40,50,51,55,59,63,64,65,66,68,69,70,71,72,75,76,77,78,81,83,90,92,93,94,96,104,105,106,111,115,119,122,127,131,140,141,142,143,147,148,149,150,157,167,171,175,176,177,193,194,195,196,197] popoffcommands = [] redstoneblockcommands = [] solidcommands = [] entitiescommand = [] if options["Include blocks"] == True: for y in reversed(xrange(box.miny,box.maxy)): for x in xrange(box.minx,box.maxx): for z in xrange(box.minz,box.maxz): cmdtemp = '' if cmdBlockPosing=="Absolute": blockX = x blockY = y blockZ = z elif cmdBlockPosing=="Relative": blockY=y-box.miny-cmdBlockHeight-2 if relativePos=="North-West": blockX=x-box.minx+2 blockZ=z-box.minz+2 if relativePos=="South-West": blockX=x-box.minx+2 blockZ=z-box.maxz-1 if relativePos=="North-East": blockX=x-box.maxx-1 blockZ=z-box.minz+2 if relativePos=="South-East": blockX=x-box.maxx-1 blockZ=z-box.maxz-1 else : raise Exception ("WTF?") if includeBlocks==True and level.blockAt(x,y,z)!=0: if level.tileEntityAt(x,y,z)==None: cmdtemp='{id:MinecartCommandBlock,Command:"setblock'+ {True: " ~", False: " "}[cmdBlockPosing=="Relative"] +str(blockX)+{True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(blockY)+{True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(blockZ)+' '+IDsToName[str(level.blockAt(x,y,z))]+' '+str(level.blockDataAt(x,y,z))+{True: " destroy", False: " replace"}[level.blockAt(x,y,z)==152]+'",Riding:' if level.tileEntityAt(x,y,z) !=None: cmdtemp= '{id:MinecartCommandBlock,Command:"setblock'+ {True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(blockX)+{True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(+blockY)+{True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(blockZ)+' '+IDsToName[str(level.blockAt(x,y,z))]+' '+str(level.blockDataAt(x,y,z))+{True: " destroy", False: " replace"}[level.blockAt(x,y,z)==152]+' {'+NBT2Command(level.tileEntityAt(x,y,z))+'}",Riding:' if includeAir==True and level.blockAt(x,y,z)==0: if level.tileEntityAt(x,y,z)==None: cmdtemp='{id:MinecartCommandBlock,Command:"setblock'+ {True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(blockX)+{True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(blockY)+{True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(blockZ)+' '+IDsToName[str(level.blockAt(x,y,z))]+' '+str(level.blockDataAt(x,y,z))+' replace",Riding:' if level.tileEntityAt(x,y,z) != None: cmdtemp='{id:MinecartCommandBlock,Command:"setblock'+ {True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(blockX)+{True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(blockY)+{True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(blockZ)+' '+IDsToName[str(level.blockAt(x,y,z))]+' '+str(level.blockDataAt(x,y,z))+' replace {'+NBT2Command(level.tileEntityAt(x,y,z))+'}",Riding:' if cmdtemp != '': if level.blockAt(x,y,z) in popOffBlocks: popoffcommands.append([cmdtemp, 1]) elif level.blockAt(x,y,z) == 152: redstoneblockcommands.append([cmdtemp, 1]) solidcommands.append([cmdtemp, 1]) else: solidcommands.append([cmdtemp, 1]) if options["Include entities"] == True: for (chunk, slices, point) in level.getChunkSlices(box): for e in chunk.Entities: ex = e["Pos"][0].value ey = e["Pos"][1].value ez = e["Pos"][2].value if (ex,ey,ez) in box: if cmdBlockPosing=="Absolute": entityX = ex entityY = ey entityZ = ez elif cmdBlockPosing=="Relative": entityY=ey-box.miny-cmdBlockHeight-2.05 if relativePos=="North-West": entityX=ex-box.minx+1.5 entityZ=ez-box.minz+1.7 if relativePos=="South-West": entityX=ex-box.minx+1.5 entityZ=ez-box.maxz-1.3 if relativePos=="North-East": entityX=ex-box.maxx-1.5 entityZ=ez-box.minz+1.7 if relativePos=="South-East": entityX=ex-box.maxx-1.5 entityZ=ez-box.maxz-1.3 else : raise Exception ("WTF?") cmdtemp= "{id:MinecartCommandBlock,Command:\"summon "+str(e["id"].value)+" "+ {True: "~", False: ""}[cmdBlockPosing=="Relative"]+str(entityX)+{True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(+entityY)+{True: " ~", False: " "}[cmdBlockPosing=="Relative"]+str(entityZ)+" {"+NBT2Command(e)+"}\",Riding:" entitiescommand.append([cmdtemp, 1]) if cmdBlockPosing=="Absolute": cmd="/summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:{id:MinecartCommandBlock,Command:/tellraw @a {text:\"Thanks to gentlegiantJGC and xafonyz for making the MCedit filter to make this possible\",color:gold},Riding:" bracketsToClose=1 if entitiescommand != []: for c in entitiescommand: if len(cmd) + len(c[0]) + bracketsToClose + c[1] + 195 > 32760: cmd+="{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="/summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += c[0] bracketsToClose += c[1] if popoffcommands != [] or redstoneblockcommands != [] or solidcommands != []: if len(cmd) + 51 + bracketsToClose + 195 > 32760: cmd+="{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="/summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += '{id:MinecartCommandBlock,Command:buffer,Riding:{id:MinecartCommandBlock,Command:buffer,Riding:' bracketsToClose += 2 if popoffcommands != []: for c in popoffcommands: if len(cmd) + len(c[0]) + bracketsToClose + c[1] + 195 > 32760: cmd+="{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="/summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += c[0] bracketsToClose += c[1] if redstoneblockcommands != [] or solidcommands != []: if len(cmd) + 51 + bracketsToClose + 195 > 32760: cmd+="{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="/summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += '{id:MinecartCommandBlock,Command:buffer,Riding:{id:MinecartCommandBlock,Command:buffer,Riding:' bracketsToClose += 2 if redstoneblockcommands != []: for c in redstoneblockcommands: if len(cmd) + len(c[0]) + bracketsToClose + c[1] + 195 > 32760: cmd+="{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="/summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += c[0] bracketsToClose += c[1] if solidcommands != []: if len(cmd) + 51 + bracketsToClose + 195 > 32760: cmd+="{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="/summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += '{id:MinecartCommandBlock,Command:buffer,Riding:{id:MinecartCommandBlock,Command:buffer,Riding:' bracketsToClose += 2 if solidcommands != []: for c in solidcommands: if len(cmd) + len(c[0]) + bracketsToClose + c[1] + 195 > 32760: cmd+="{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="/summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += c[0] bracketsToClose += c[1] cmd+="{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) schematic = MCSchematic((len(commandlist)*2-1, 1, 1), mats=level.materials) cx = 0 for command in commandlist: schematic.setBlockAt(cx, 0, 0, 137) schematic.setBlockDataAt(cx, 0, 0, 0) control = TAG_Compound() control["id"] = TAG_String(u'Control') control["CustomName"] = TAG_String(u"builder") control["z"] = TAG_Int(0) control["y"] = TAG_Int(0) control["x"] = TAG_Int(cx) control["Command"] = TAG_String(command) schematic.TileEntities.append(control) cx += 2 editor.addCopiedSchematic(schematic) if cmdBlockPosing=="Relative": cmd="summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:{id:MinecartCommandBlock,Command:/tellraw @a {text:\"Thanks to gentlegiantJGC and xafonyz for making the MCedit filter to make this possible\",color:gold},Riding:" bracketsToClose=1 if entitiescommand != []: for c in entitiescommand: if len(cmd) + len(c[0]) + bracketsToClose + c[1] + 195 > 32710: cmd = "/execute @e[name=OCSSMarker,type=ArmorStand] ~ ~ ~ "+cmd+"{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += c[0] bracketsToClose += c[1] if popoffcommands != [] or redstoneblockcommands != [] or solidcommands != []: if len(cmd) + 51 + bracketsToClose + 195 > 32710: cmd = "/execute @e[name=OCSSMarker,type=ArmorStand] ~ ~ ~ "+cmd+"{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += '{id:MinecartCommandBlock,Command:buffer,Riding:{id:MinecartCommandBlock,Command:buffer,Riding:' bracketsToClose += 2 if popoffcommands != []: for c in popoffcommands: if len(cmd) + len(c[0]) + bracketsToClose + c[1] + 195 > 32710: cmd="/execute @e[name=OCSSMarker,type=ArmorStand] ~ ~ ~ "+cmd+"{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += c[0] bracketsToClose += c[1] if redstoneblockcommands != [] or solidcommands != []: if len(cmd) + 51 + bracketsToClose + 195 > 32710: cmd="/execute @e[name=OCSSMarker,type=ArmorStand] ~ ~ ~ "+cmd+"{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += '{id:MinecartCommandBlock,Command:buffer,Riding:{id:MinecartCommandBlock,Command:buffer,Riding:' bracketsToClose += 2 if redstoneblockcommands != []: for c in redstoneblockcommands: if len(cmd) + len(c[0]) + bracketsToClose + c[1] + 195 > 32710: cmd = "/execute @e[name=OCSSMarker,type=ArmorStand] ~ ~ ~ "+cmd+"{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += c[0] bracketsToClose += c[1] if solidcommands != []: if len(cmd) + 51 + bracketsToClose + 195 > 32710: cmd = "/execute @e[name=OCSSMarker,type=ArmorStand] ~ ~ ~ "+cmd+"{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += '{id:MinecartCommandBlock,Command:buffer,Riding:{id:MinecartCommandBlock,Command:buffer,Riding:' bracketsToClose += 2 if solidcommands != []: for c in solidcommands: if len(cmd) + len(c[0]) + bracketsToClose + c[1] + 195 > 32710: cmd = "/execute @e[name=OCSSMarker,type=ArmorStand] ~ ~ ~ "+cmd+"{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 commandlist.append(cmd) cmd="summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:" bracketsToClose=0 cmd += c[0] bracketsToClose += c[1] cmd+="{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}" while bracketsToClose > 0: cmd += "}" bracketsToClose -= 1 if len(commandlist) > 0: cmd = "/execute @e[name=OCSSMarker,type=ArmorStand] ~ ~ ~ "+cmd commandlist.append(cmd) if len(commandlist) == 1: schematic = MCSchematic((1, 1, 1), mats=level.materials) for command in commandlist: schematic.setBlockAt(0, 0, 0, 137) schematic.setBlockDataAt(0, 0, 0, 0) control = TAG_Compound() control["id"] = TAG_String(u'Control') control["CustomName"] = TAG_String(u"builder") control["z"] = TAG_Int(0) control["y"] = TAG_Int(0) control["x"] = TAG_Int(0) control["Command"] = TAG_String(command) schematic.TileEntities.append(control) editor.addCopiedSchematic(schematic) else: schematic = MCSchematic((len(commandlist)*2+1, 1, 1), mats=level.materials) cx = 2 for command in commandlist: schematic.setBlockAt(cx, 0, 0, 137) schematic.setBlockDataAt(cx, 0, 0, 0) control = TAG_Compound() control["id"] = TAG_String(u'Control') control["CustomName"] = TAG_String(u"builder") control["z"] = TAG_Int(0) control["y"] = TAG_Int(0) control["x"] = TAG_Int(cx) control["Command"] = TAG_String(command) schematic.TileEntities.append(control) cx += 2 schematic.setBlockAt(0, 0, 0, 137) schematic.setBlockDataAt(0, 0, 0, 0) control = TAG_Compound() control["id"] = TAG_String(u'Control') control["CustomName"] = TAG_String(u"builder") control["z"] = TAG_Int(0) control["y"] = TAG_Int(0) control["x"] = TAG_Int(0) control["Command"] = TAG_String('/summon FallingSand ~ ~+4 ~ {Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:fill ~ ~1 ~-1 ~ ~-5 ~ air},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:FallingSand,Time:1,Block:minecraft:command_block,TileEntityData:{Command:kill @e[type=MinecartCommandBlock,r=4]},Riding:{id:FallingSand,Time:1,Data:0,TileID:1,Riding:{id:MinecartCommandBlock,Command:setblock ~ ~ ~ air,Riding:{id:MinecartCommandBlock,Command:/kill @e[type=Item,r=4],Riding:{id:MinecartCommandBlock,Command:"/summon ArmorStand ~ ~-1.05 ~0.3125 {CustomName:OCSSMarker,NoGravity:1}",Riding:{id:MinecartCommandBlock,Command:"setblock ~ ~-2 ~ stone",Riding:{id:MinecartCommandBlock,Command:buffer,Riding:{id:FallingSand,Time:1,Data:0,TileID:157,Riding:{id:FallingSand,Time:1,Data:0,TileID:152,Riding:{id:Item,Age:5996,Motion:[0.0,0.0,-0.1]}}}}}}}}}}}}}}') schematic.TileEntities.append(control) editor.addCopiedSchematic(schematic)