Beispiel #1
0
 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)
Beispiel #2
0
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
Beispiel #3
0
    def exportSchematicIter(self, selection):
        schematic = createSchematic(shape=selection.size,
                                    blocktypes=self.blocktypes)

        return itertools.chain(
            copyBlocksIter(schematic.getDimension(), self, selection,
                           (0, 0, 0)), [schematic])
Beispiel #4
0
 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)
Beispiel #5
0
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
Beispiel #6
0
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
Beispiel #7
0
 def importSchematicIter(self, schematic, destPoint):
     dim = schematic.getDimension()
     return copyBlocksIter(self,
                           dim,
                           dim.bounds,
                           destPoint,
                           biomes=True,
                           create=True)
Beispiel #8
0
 def copyBlocksIter(self,
                    sourceLevel,
                    sourceSelection,
                    destinationPoint,
                    blocksToCopy=None,
                    entities=True,
                    create=False,
                    biomes=False):
     return copyBlocksIter(self, sourceLevel, sourceSelection,
                           destinationPoint, blocksToCopy, entities, create,
                           biomes)
Beispiel #9
0
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
Beispiel #10
0
 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
     )
Beispiel #11
0
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
Beispiel #12
0
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
Beispiel #13
0
    def exportSchematicIter(self, selection):
        schematic = createSchematic(shape=selection.size, blocktypes=self.blocktypes)

        return itertools.chain(copyBlocksIter(schematic.getDimension(), self, selection, (0, 0, 0)), [schematic])
Beispiel #14
0
 def copyBlocksIter(self, *a, **kw):
     return copyBlocksIter(self, *a, **kw)
Beispiel #15
0
 def importSchematicIter(self, schematic, destPoint):
     dim = schematic.getDimension()
     return copyBlocksIter(self, dim, dim.bounds, destPoint, biomes=True, create=True)
Beispiel #16
0
 def copyBlocksIter(self, *a, **kw):
     return copyBlocksIter(self, *a, **kw)