def importSchematicIter(self, schematic, destPoint): if hasattr(schematic, 'getDimension'): # accept either WorldEditor or WorldEditorDimension dim = schematic.getDimension() else: dim = schematic return copyBlocksIter(self, dim, dim.bounds, destPoint, biomes=True, create=True)
def extractSchematicFromIter(sourceDim, box, *a, **kw): editor = createSchematic(shape=box.size, blocktypes=sourceDim.blocktypes) dim = editor.getDimension() for i in copyBlocksIter(dim, sourceDim, box, (0, 0, 0), *a, **kw): yield i yield editor
def exportSchematicIter(self, selection): schematic = createSchematic(shape=selection.size, blocktypes=self.blocktypes) return itertools.chain( copyBlocksIter(schematic.getDimension(), self, selection, (0, 0, 0)), [schematic])
def extractZipSchematicFromIter(sourceLevel, box, zipfilename=None, entities=True): # converts classic blocks to alpha # probably should only apply to alpha levels if zipfilename is None: zipfilename = tempfile.mktemp("zipschematic.zip") atexit.register(shutil.rmtree, zipfilename, True) p = adjustExtractionParameters(sourceLevel, box) if p is None: return sourceBox, destPoint = p destPoint = (0, 0, 0) tempSchematic = mceditlib.schematic.ZipSchematic(zipfilename, create=True) tempSchematic.blocktypes = sourceLevel.blocktypes for i in copyBlocksIter(tempSchematic, sourceLevel, sourceBox, destPoint, entities=entities, create=True, biomes=True): yield i tempSchematic.Width, tempSchematic.Height, tempSchematic.Length = sourceBox.size tempSchematic.saveChanges( ) # lights not needed for this format - crashes minecraft though yield tempSchematic
def importSchematicIter(self, schematic, destPoint): dim = schematic.getDimension() return copyBlocksIter(self, dim, dim.bounds, destPoint, biomes=True, create=True)
def copyBlocksIter(self, sourceLevel, sourceSelection, destinationPoint, blocksToCopy=None, entities=True, create=False, biomes=False): return copyBlocksIter(self, sourceLevel, sourceSelection, destinationPoint, blocksToCopy, entities, create, biomes)
def extractSchematicFromIter(sourceDim, box, entities=True): p = adjustExtractionParameters(sourceDim, box) if p is None: yield None return newbox, destPoint = p editor = createSchematic(shape=box.size, blocktypes=sourceDim.blocktypes) dim = editor.getDimension() for i in copyBlocksIter(dim, sourceDim, newbox, destPoint, entities=entities, biomes=True): yield i yield editor
def copyBlocksIter( self, sourceLevel, sourceSelection, destinationPoint, blocksToCopy=None, entities=True, create=False, biomes=False, updateLights=False, ): return copyBlocksIter( self, sourceLevel, sourceSelection, destinationPoint, blocksToCopy, entities, create, biomes, updateLights )
def extractZipSchematicFromIter(sourceLevel, box, zipfilename=None, entities=True): # converts classic blocks to alpha # probably should only apply to alpha levels if zipfilename is None: zipfilename = tempfile.mktemp("zipschematic.zip") atexit.register(shutil.rmtree, zipfilename, True) p = adjustExtractionParameters(sourceLevel, box) if p is None: return sourceBox, destPoint = p destPoint = (0, 0, 0) tempSchematic = mceditlib.schematic.ZipSchematic(zipfilename, create=True) tempSchematic.blocktypes = sourceLevel.blocktypes for i in copyBlocksIter(tempSchematic, sourceLevel, sourceBox, destPoint, entities=entities, create=True, biomes=True): yield i tempSchematic.Width, tempSchematic.Height, tempSchematic.Length = sourceBox.size tempSchematic.saveChanges() # lights not needed for this format - crashes minecraft though yield tempSchematic
def exportSchematicIter(self, selection): schematic = createSchematic(shape=selection.size, blocktypes=self.blocktypes) return itertools.chain(copyBlocksIter(schematic.getDimension(), self, selection, (0, 0, 0)), [schematic])
def copyBlocksIter(self, *a, **kw): return copyBlocksIter(self, *a, **kw)