def testCopyRelight(anvilLevel, sourceLevel): destDim = anvilLevel.getDimension() exhaust( destDim.copyBlocksIter(sourceLevel.getDimension(), BoundingBox((0, 0, 0), ( 32, 64, 32, )), destDim.bounds.origin)) anvilLevel.saveChanges()
def testCopyRelight(pc_world, schematic_world): destDim = pc_world.getDimension() exhaust( destDim.copyBlocksIter(schematic_world.getDimension(), BoundingBox((0, 0, 0), ( 32, 64, 32, )), destDim.bounds.origin)) pc_world.saveChanges()
def timeFillCeiling(): temp = bench_temp_level("AnvilWorld") editor = temp dim = editor.getDimension() bounds = dim.bounds x, y, z = bounds.center y = 254 x -= size // 2 z -= size // 2 bounds = BoundingBox((x, y, z), (size, 1, size)) exhaust(dim.fillBlocksIter(bounds, editor.blocktypes["planks"]))
def timeFillCeiling(): temp = bench_temp_level("AnvilWorld") editor = temp dim = editor.getDimension() bounds = dim.bounds x, y, z = bounds.center y = 254 x -= size//2 z -= size//2 bounds = BoundingBox((x, y, z), (size, 1, size)) exhaust(dim.fillBlocksIter(bounds, editor.blocktypes["planks"]))
def updateSelection(self): if self.dimension is None or self.selection is None: return selection = self.selection self.renderSelection = selection & NonAirMaskSelection(self.dimension, selection) self.groupNode.clear() self._loader = None if selection.chunkCount < 16: exhaust(self.loadSections()) self.loadTimer.setInterval(333)
def exportSchematic(self, selection): """ :type selection: mceditlib.box.BoundingBox :return: :rtype: WorldEditor """ return exhaust(self.exportSchematicIter(selection))
def copyBlocks(self, sourceLevel, sourceSelection, destinationPoint, blocksToCopy=None, entities=True, create=False, biomes=False): return exhaust( self.copyBlocksIter(sourceLevel, sourceSelection, destinationPoint, blocksToCopy, entities, create, biomes))
def displaySchematic(self, schematic, offset): if schematic is not None: dim = schematic.getDimension() if self.worldScene: self.sceneHolderNode.removeChild(self.worldScene) self.loader.timer.stop() self.loader = None atlas = self.editorSession.textureAtlas self.worldScene = WorldScene(dim, atlas) self.sceneTranslate.translateOffset = offset self.sceneHolderNode.addChild(self.worldScene) self.loader = WorldLoader(self.worldScene) if dim.chunkCount() <= self.instantDisplayChunks: exhaust(self.loader.work()) else: self.loader.startLoader() else: self.clearSchematic()
def displaySchematic(self, schematic, offset): if schematic is not None: dim = schematic.getDimension() if self.worldScene: self.sceneHolderNode.removeChild(self.worldScene) self.loader.timer.stop() self.loader = None atlas = self.editorSession.textureAtlas self.worldScene = WorldScene(dim, atlas) self.sceneHolderNode.translateOffset = offset self.sceneHolderNode.addChild(self.worldScene) self.loader = WorldLoader(self.worldScene) if dim.chunkCount() <= self.instantDisplayChunks: exhaust(self.loader.work()) else: self.loader.timer.start() else: self.clearSchematic()
def copyBlocks( self, sourceLevel, sourceSelection, destinationPoint, blocksToCopy=None, entities=True, create=False, biomes=False, updateLights=False, ): return exhaust( self.copyBlocksIter( sourceLevel, sourceSelection, destinationPoint, blocksToCopy, entities, create, biomes, updateLights ) )
def extractSchematicFrom(sourceDim, box, *a, **kw): """ Extract a schematic from the given dimension within the given selection box. The minimum corner of the given box becomes the schematic's (0,0,0) coordinate. Parameters ---------- sourceDim : WorldEditorDimension box : SelectionBox a : kw : Returns ------- WorldEditor """ return exhaust(extractSchematicFromIter(sourceDim, box, *a, **kw))
def copyBlocks(self, *a, **kw): return exhaust(self.copyBlocksIter(*a, **kw))
def syncToDisk(self): exhaust(self.syncToDiskIter())
def saveChanges(self): exhaust(self.saveChangesIter())
def showProgress(text, *tasks, **kwargs): """ Show a progress dialog for the given task(s). Each task should be an iterable, yielding progress info as (current, max) or (current, max, statusString) tuples. Return the last value yielded by the task. :param text: :type text: :param iter: :type iter: :param cancel: :type cancel: :return: :rtype: """ global _progressBarActive if _progressBarActive: for task in tasks: exhaust(task) return progress = None cancel = kwargs.pop('cancel', None) start = time.time() shown = False try: with LoaderTimer.stopCtx(): dialog = MCEProgressDialog(QtGui.qApp.mainWindow) if not cancel: dialog.setCancelButtonText(None) dialog.setWindowTitle(text) dialog.setWindowModality(Qt.WindowModal) log.info("Starting progress: %d tasks." % len(tasks)) totalMaximum = len(tasks) * 100 for i, task in enumerate(tasks): log.info("Task #%d", i) task = rescaleProgress(task, i * 100, i * 100 + 100) for progress in task: if isinstance(progress, basestring): current = 0 maximum = 0 status = progress elif isinstance(progress, tuple): if len(progress) > 2: current, maximum, status = progress[:3] else: current, maximum = progress status = "" else: current = 0 maximum = 0 status = "" dialog.setValue(current) if maximum == 0: # Task progress is indeterminate dialog.setMaximum(0) else: dialog.setMaximum(totalMaximum) dialog.setLabelText(status) if time.time() > start + timeBeforeDialog: if not shown: dialog.show() shown = True QtGui.QApplication.processEvents() if dialog.wasCanceled(): return False dialog.reset() return progress finally: _progressBarActive = False
def loadImmediateChunks(self): if self.selection.chunkCount < 16: exhaust(self.loadSections()) self.loadTimer.setInterval(333)
def fillBlocks(self, box, block, blocksToReplace=(), updateLights=True): return exhaust( self.fillBlocksIter(box, block, blocksToReplace, updateLights))
def timeFill(): temp = TempLevel("AnvilWorld") editor = temp dim = editor.getDimension() editor.loadedChunkLimit = 1 exhaust(dim.fillBlocksIter(dim.bounds, editor.blocktypes.OakWoodPlanks))
def commitUndo(self, revisionInfo=None): exhaust(self.commitUndoIter(revisionInfo))
def commitUndo(self): exhaust(self.commitUndoIter())
def createLevel(self, level, box, simulate=False, **kw): return exhaust(self.createLevelIter(level, box, simulate, **kw))
def extractAnySchematic(level, box): return exhaust(level.extractAnySchematicIter(box))
def extractZipSchematicFrom(sourceLevel, box, zipfilename=None, entities=True): return exhaust(extractZipSchematicFromIter(sourceLevel, box, zipfilename, entities))
def extractSchematicFrom(sourceDim, box, entities=True): return exhaust(extractSchematicFromIter(sourceDim, box, entities))
def generateChunksInLevel(self, level, chunks): return exhaust(self.generateChunksInLevelIter(level, chunks))
def extractSchematicFrom(sourceDim, box, *a, **kw): return exhaust(extractSchematicFromIter(sourceDim, box, *a, **kw))
def perform(self): if len(self.points) > 10: showProgress("Performing brush...", self._perform(), cancel=True) else: exhaust(self._perform())
def generateAtPosition(self, tempWorld, tempDir, cx, cz): return exhaust(self.generateAtPositionIter(tempWorld, tempDir, cx, cz))
def showProgress(text, *tasks, **kwargs): """ Show a progress dialog for the given task(s). Each task should be an iterable, yielding progress info as (current, max) or (current, max, statusString) tuples. Return the last value yielded by the task. :param text: :type text: :param iter: :type iter: :param cancel: :type cancel: :return: :rtype: """ global _progressBarActive if _progressBarActive: for task in tasks: exhaust(task) return progress = None cancel = kwargs.pop('cancel', None) start = time.time() shown = False try: with LoaderTimer.stopCtx(): dialog = MCEProgressDialog(QtGui.qApp.mainWindow) if not cancel: dialog.setCancelButtonText(None) dialog.setWindowTitle(text) dialog.setWindowModality(Qt.WindowModal) log.info("Starting progress: %d tasks." % len(tasks)) totalMaximum = len(tasks) * 100 for i, task in enumerate(tasks): log.info("Task #%d", i) task = rescaleProgress(task, i*100, i*100+100) for progress in task: if isinstance(progress, basestring): current = 0 maximum = 0 status = progress elif isinstance(progress, tuple): if len(progress) > 2: current, maximum, status = progress[:3] else: current, maximum = progress status = "" else: current = 0 maximum = 0 status = "" dialog.setValue(current) if maximum == 0: # Task progress is indeterminate dialog.setMaximum(0) else: dialog.setMaximum(totalMaximum) dialog.setLabelText(status) if time.time() > start + timeBeforeDialog: if not shown: dialog.show() shown = True QtGui.QApplication.processEvents() if dialog.wasCanceled(): return False dialog.reset() return progress finally: _progressBarActive = False
def testCopyRelight(anvilLevel, sourceLevel): destDim = anvilLevel.getDimension() exhaust(destDim.copyBlocksIter(sourceLevel.getDimension(), BoundingBox((0, 0, 0), (32, 64, 32,)), destDim.bounds.origin)) anvilLevel.saveChanges()
def extractZipSchematicFrom(sourceLevel, box, zipfilename=None, entities=True): return exhaust( extractZipSchematicFromIter(sourceLevel, box, zipfilename, entities))
def fillBlocks(self, box, block, blocksToReplace=(), updateLights=True): return exhaust(self.fillBlocksIter(box, block, blocksToReplace, updateLights))
def timeFill(): temp = bench_temp_level("AnvilWorld") editor = temp dim = editor.getDimension() editor.loadedChunkLimit = 1 exhaust(dim.fillBlocksIter(dim.bounds, editor.blocktypes.OakWoodPlanks))
def testCopyRelight(pc_world, schematic_world): destDim = pc_world.getDimension() exhaust(destDim.copyBlocksIter(schematic_world.getDimension(), BoundingBox((0, 0, 0), (32, 64, 32,)), destDim.bounds.origin)) pc_world.saveChanges()