Example #1
0
 def deleteBlocks(self):
     command = SimpleRevisionCommand(self, "Delete Blocks")
     with command.begin():
         fillTask = self.currentDimension.fillBlocksIter(
             self.currentSelection, "air")
         showProgress("Deleting...", fillTask)
     self.pushCommand(command)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
 def deleteEntities(self):
     command = SimpleRevisionCommand(self, "Delete Entities")
     with command.begin():
         entitiesTask = RemoveEntitiesOperation(self.currentDimension,
                                                self.currentSelection)
         showProgress("Deleting...", entitiesTask)
     self.pushCommand(command)
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 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)
Example #8
0
 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)
Example #9
0
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)
Example #10
0
 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)
Example #11
0
    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)
Example #12
0
    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)
Example #13
0
 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)
Example #14
0
 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)
Example #15
0
    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.")
Example #16
0
    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.")
Example #17
0
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)
Example #18
0
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)
Example #19
0
    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)
Example #20
0
 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)
Example #21
0
 def deleteEntities(self):
     command = SimpleRevisionCommand(self, "Delete Entities")
     with command.begin():
         entitiesTask = RemoveEntitiesOperation(self.currentDimension, self.currentSelection)
         showProgress("Deleting...", entitiesTask)
     self.pushCommand(command)
Example #22
0
 def deleteBlocks(self):
     command = SimpleRevisionCommand(self, "Delete Blocks")
     with command.begin():
         fillTask = self.currentDimension.fillBlocksIter(self.currentSelection, "air")
         showProgress("Deleting...", fillTask)
     self.pushCommand(command)