예제 #1
0
    def setupPreview(self):
        """
        Creates the Brush Preview
        Passes it as a FakeLevel object to the renderer
        Called whenever the preview needs to be recalculated
        """
        brushSize = self.getBrushSize()
        brushStyle = self.options['Style']
        key = getattr(self.brushMode, 'mainBlock', 'Block')
        blockInfo = self.options[key]

        class FakeLevel(pymclevel.MCLevel):
            filename = "Fake Level"
            materials = self.editor.level.materials
            root_tag = "Dummy"

            _gamePlatform = "Unknown"

            def __init__(self):
                self.chunkCache = {}

            Width, Height, Length = brushSize
            if self.editor.level.gamePlatform == "PE" and self.editor.level.world_version == "1.plus":
                Height = 16
            else:
                Height = self.editor.level.Height
            zerolight = numpy.zeros((16, 16, Height), dtype='uint8')
            zerolight[:] = 15

            def getChunk(self, cx, cz):
                if (cx, cz) in self.chunkCache:
                    return self.chunkCache[cx, cz]

                class FakeBrushChunk(pymclevel.level.FakeChunk):
                    Entities = []
                    TileEntities = []

                f = FakeBrushChunk()
                f.world = self
                f.chunkPosition = (cx, cz)

                mask = createBrushMask(
                    brushSize, brushStyle, (0, 0, 0),
                    BoundingBox((cx << 4, 0, cz << 4), (16, self.Height, 16)))
                f.Blocks = numpy.zeros(mask.shape, dtype='uint8')
                f.Data = numpy.zeros(mask.shape, dtype='uint8')
                f.BlockLight = self.zerolight
                f.SkyLight = self.zerolight

                if blockInfo.ID:
                    f.Blocks[mask] = blockInfo.ID
                    f.Data[mask] = blockInfo.blockData

                else:
                    f.Blocks[mask] = 255
                self.chunkCache[cx, cz] = f
                return f

        self.level = FakeLevel()
        CloneTool.setupPreview(self, alpha=self.settings['brushAlpha'])
예제 #2
0
    def setupPreview(self):
        """
        Creates the Brush Preview
        Passes it as a FakeLevel object to the renderer
        Called whenever the preview needs to be recalculated
        """
        brushSize = self.getBrushSize()
        brushStyle = self.options['Style']
        key = getattr(self.brushMode, 'mainBlock', 'Block')
        blockInfo = self.options[key]

        class FakeLevel(pymclevel.MCLevel):
            filename = "Fake Level"
            materials = self.editor.level.materials
            root_tag = "Dummy"

            _gamePlatform = "Unknown"

            def __init__(self):
                self.chunkCache = {}

            Width, Height, Length = brushSize
            if self.editor.level.gamePlatform == "PE" and self.editor.level.world_version == "1.plus":
                Height = 16
            else:
                Height = self.editor.level.Height
            zerolight = numpy.zeros((16, 16, Height), dtype='uint8')
            zerolight[:] = 15

            def getChunk(self, cx, cz):
                if (cx, cz) in self.chunkCache:
                    return self.chunkCache[cx, cz]

                class FakeBrushChunk(pymclevel.level.FakeChunk):
                    Entities = []
                    TileEntities = []

                f = FakeBrushChunk()
                f.world = self
                f.chunkPosition = (cx, cz)

                mask = createBrushMask(brushSize, brushStyle, (0, 0, 0), BoundingBox((cx << 4, 0, cz << 4), (16, self.Height, 16)))
                f.Blocks = numpy.zeros(mask.shape, dtype='uint8')
                f.Data = numpy.zeros(mask.shape, dtype='uint8')
                f.BlockLight = self.zerolight
                f.SkyLight = self.zerolight

                if blockInfo.ID:
                    f.Blocks[mask] = blockInfo.ID
                    f.Data[mask] = blockInfo.blockData

                else:
                    f.Blocks[mask] = 255
                self.chunkCache[cx, cz] = f
                return f

        self.level = FakeLevel()
        CloneTool.setupPreview(self, alpha=self.settings['brushAlpha'])
예제 #3
0
 def __init__(self, *args):
     """
     Called on starting mcedit.
     Creates some basic variables.
     """
     CloneTool.__init__(self, *args)
     self.optionsPanel = BrushToolOptions(self)
     self.recentFillBlocks = []
     self.recentReplaceBlocks = []
     self.draggedPositions = []
     self.pickBlockKey = False
     self.lineToolKey = False
     self.lastPosition = None
     self.root = get_root()
예제 #4
0
 def __init__(self, *args):
     """
     Called on starting mcedit.
     Creates some basic variables.
     """
     CloneTool.__init__(self, *args)
     self.optionsPanel = BrushToolOptions(self)
     self.recentFillBlocks = []
     self.recentReplaceBlocks = []
     self.draggedPositions = []
     self.pickBlockKey = False
     self.lineToolKey = False
     self.lastPosition = None
     self.root = get_root()
예제 #5
0
 def loadLevel(self, level):
     self.level = level
     self.options['Minimum Spacing'] = min([s / 4 for s in level.size])
     CloneTool.setupPreview(self, alpha = self.settings['brushAlpha'])
예제 #6
0
 def loadLevel(self, level):
     self.level = level
     self.options['Minimum Spacing'] = min([s / 4 for s in level.size])
     CloneTool.setupPreview(self, alpha=self.settings['brushAlpha'])