def deleteBlocks(self): command = SimpleRevisionCommand(self, "Delete Blocks") with command.begin(): fillTask = self.currentDimension.fillBlocksIter( self.currentSelection, "air") showProgress("Deleting...", fillTask) self.pushCommand(command)
def removeEntity(self): if self.entity is None: return command = SimpleRevisionCommand(self.editorSession, "Remove Entity") with command.begin(): self.entity.chunk.Entities.remove(self.entity)
def deleteEntities(self): command = SimpleRevisionCommand(self, "Delete Entities") with command.begin(): entitiesTask = RemoveEntitiesOperation(self.currentDimension, self.currentSelection) showProgress("Deleting...", entitiesTask) self.pushCommand(command)
def cut(self): command = SimpleRevisionCommand(self, "Cut") with command.begin(): task = self.currentDimension.exportSchematicIter(self.currentSelection) self.copiedSchematic = showProgress("Cutting...", task) task = self.currentDimension.fillBlocksIter(self.currentSelection, "air") showProgress("Cutting...", task) self.undoStack.push(command)
def deleteSelection(self): command = SimpleRevisionCommand(self, "Delete") with command.begin(): fillTask = self.currentDimension.fillBlocksIter(self.currentSelection, "air") entitiesTask = RemoveEntitiesOperation(self.currentDimension, self.currentSelection) task = ComposeOperations(fillTask, entitiesTask) showProgress("Deleting...", task) self.pushCommand(command)
def replaceCommand(editorSession): dialog = ReplaceDialog(editorSession) if dialog.exec_(): replacements = dialog.getReplacements() command = SimpleRevisionCommand(editorSession, "Replace") with command.begin(): task = editorSession.currentDimension.fillBlocksIter(editorSession.currentSelection, replacements) showProgress("Replacing...", task) editorSession.pushCommand(command)
def doReplace(self): replacements = self.getReplacements() command = SimpleRevisionCommand(self.editorSession, "Replace") selection = self.editorSession.currentDimension.bounds # selection = self.editorSession.currentSelection with command.begin(): task = self.editorSession.currentDimension.fillBlocksIter(selection, replacements, updateLights=False) showProgress("Replacing...", task) self.editorSession.pushCommand(command)
def deleteChunks(self): if self.currentSelection is None: return command = SimpleRevisionCommand(self, self.tr("Delete Chunks")) with command.begin(): for cx in range(self.currentSelection.mincx, self.currentSelection.maxcx): for cz in range(self.currentSelection.mincz, self.currentSelection.maxcz): self.currentDimension.deleteChunk(cx, cz) self.pushCommand(command)
def doReplace(self): replacements = self.widget.replacementList.getReplacements() command = SimpleRevisionCommand(self.editorSession, "Replace") if self.widget.replaceBlocksInSelectionCheckbox.isChecked(): selection = self.editorSession.currentSelection else: selection = self.editorSession.currentDimension.bounds with command.begin(): task = self.editorSession.currentDimension.fillBlocksIter(selection, replacements, updateLights=False) showProgress("Replacing...", task) self.editorSession.pushCommand(command)
def doReplace(self): replacements = self.widget.replacementList.getReplacements() command = SimpleRevisionCommand(self.editorSession, "Replace") if self.widget.replaceBlocksInSelectionCheckbox.isChecked(): selection = self.editorSession.currentSelection else: selection = self.editorSession.currentDimension.bounds with command.begin(): task = self.editorSession.currentDimension.fillBlocksIter( selection, replacements) showProgress("Replacing...", task) self.editorSession.pushCommand(command)
def movePlayerToCamera(self): view = self.editorSession.editorTab.currentView() if view.viewID == "Cam": command = SimpleRevisionCommand(self.editorSession, "Move Player") with command.begin(): self.selectedPlayer.Position = view.centerPoint try: self.selectedPlayer.Rotation = view.yawPitch except AttributeError: pass self.selectedPlayer.dirty = True # xxx do in AnvilPlayerRef self.editorSession.pushCommand(command) else: raise ValueError("Current view is not camera view.")
def fillCommand(editorSession): """ :type editorSession: mcedit2.editorsession.EditorSession """ box = editorSession.currentSelection if box is None or box.volume == 0: return widget = getFillWidget(editorSession) if widget.exec_(): command = SimpleRevisionCommand(editorSession, "Fill") with command.begin(): task = editorSession.currentDimension.fillBlocksIter(box, widget.blockTypeInput.block) showProgress("Filling...", task) editorSession.pushCommand(command)
def mapItemWasDropped(self, mimeData, position, face): log.info("Map item dropped.") assert mimeData.hasFormat(MimeFormats.MapItem) mapIDString = mimeData.data(MimeFormats.MapItem).data() mapIDs = mapIDString.split(", ") mapIDs = [int(m) for m in mapIDs] mapID = mapIDs[0] # xxx only one at a time for now position = position + face.vector x, y, z = position cx = x >> 4 cz = z >> 4 try: chunk = self.currentDimension.getChunk(cx, cz) except ChunkNotPresent: log.info("Refusing to import map into non-existent chunk %s", (cx, cz)) return ref = self.worldEditor.createEntity("ItemFrame") if ref is None: return facing = ref.facingForMCEditFace(face) if facing is None: # xxx by camera vector? facing = ref.SouthFacing ref.Item.Damage = mapID ref.Item.id = "minecraft:filled_map" ref.Position = position + (0.5, 0.5, 0.5) ref.TilePos = position # 1.7/1.8 issues should be handled by ref... ref.Facing = facing log.info("Created map ItemFrame with ID %s, importing...", mapID) command = SimpleRevisionCommand(self, self.tr("Import map %(mapID)s") % {"mapID": mapID}) with command.begin(): chunk.addEntity(ref) log.info(nbt.nested_string(ref.rootTag)) self.pushCommand(command)
def showDialog(self): dialog = SimpleOptionsDialog(self.displayName, self.options, self.editorSession) result = dialog.exec_() if result == QtGui.QDialog.Accepted: command = SimpleRevisionCommand(self.editorSession, self.displayName) with self.editorSession.beginCommand(command): result = self.perform(self.editorSession.currentDimension, self.editorSession.currentSelection, dialog.getOptions()) if result is not None: self.editorSession.placeSchematic(result, name=self.displayName)
def deleteBlocks(self): command = SimpleRevisionCommand(self, "Delete Blocks") with command.begin(): fillTask = self.currentDimension.fillBlocksIter(self.currentSelection, "air") showProgress("Deleting...", fillTask) self.pushCommand(command)