Exemplo n.º 1
0
    def createTestBoard(self, anyBlock=True):
        if anyBlock:
            allBlocks = [
                self.editor.level.materials[a, b] for a in range(256)
                for b in range(16)
            ]
            blockWidth = 64
        else:
            allBlocks = self.editor.level.materials.allBlocks
            blockWidth = 16
        blockCount = len(allBlocks)

        width = blockWidth * 3 + 1
        rows = blockCount // blockWidth + 1
        length = rows * 3 + 1
        height = 3

        schematic = pymclevel.MCSchematic((width, height, length),
                                          mats=self.editor.level.materials)
        schematic.Blocks[:, :, 0] = 1

        for i, block in enumerate(allBlocks):
            col = (i % blockWidth) * 3 + 1
            row = (i // blockWidth) * 3
            schematic.Blocks[col:col + 2, row:row + 2, 2] = block.ID
            schematic.Data[col:col + 2, row:row + 2, 2] = block.blockData

        return schematic
Exemplo n.º 2
0
    def rescaleLevel(self, factor):
        # if self.level.cloneToolScaleFactor == newFactor:
        # return
        # oldfactor = self.level.cloneToolScaleFactor
        # factor = newFactor / oldfactor
        if factor == 1:
            self.level = self.originalLevel
            self.setupPreview()
            return

        oldshape = self.originalLevel.Blocks.shape
        blocks = self.originalLevel.Blocks
        data = self.originalLevel.Data

        if factor < 1.0:
            roundedShape = map(lambda x: int(int(x * factor) / factor),
                               oldshape)
            roundedSlices = map(lambda x: slice(0, x), roundedShape)
            blocks = blocks[roundedSlices]
            data = data[roundedSlices]
        else:
            roundedShape = oldshape

        newshape = map(lambda x: int(x * factor), oldshape)
        xyzshape = newshape[0], newshape[2], newshape[1]
        newlevel = pymclevel.MCSchematic(xyzshape,
                                         mats=self.editor.level.materials)

        srcgrid = numpy.mgrid[0:roundedShape[0]:1.0 / factor,
                              0:roundedShape[1]:1.0 / factor,
                              0:roundedShape[2]:1.0 / factor].astype('uint')
        dstgrid = numpy.mgrid[0:newshape[0], 0:newshape[1],
                              0:newshape[2]].astype('uint')
        srcgrid = srcgrid[map(slice, dstgrid.shape)]
        dstgrid = dstgrid[map(slice, srcgrid.shape)]

        def copyArray(dest, src):
            dest[dstgrid[0], dstgrid[1],
                 dstgrid[2]] = src[srcgrid[0], srcgrid[1], srcgrid[2]]

        copyArray(newlevel.Blocks, blocks)
        copyArray(newlevel.Data, data)

        self.level = newlevel
        self.setupPreview()
Exemplo n.º 3
0
    def blockInfo(self, b):
        if self._blockInfo != b:
            if self.thumb:
                self.thumb.set_parent(None)
            self._blockInfo = b
            if b is None:
                return

            sch = pymclevel.MCSchematic(shape=(1, 1, 1), mats=self.materials)
            if b:
                sch.Blocks[:] = b.ID
                sch.Data[:] = b.blockData

            self.thumb = ThumbView(sch)
            self.add(self.thumb)
            self.thumb.size = self.size
            self.thumb.drawBackground = False
            for _ in self.thumb.renderer.chunkWorker:
                pass
Exemplo n.º 4
0
    def rescaleLevel(self, factor):
        if factor == 1:
            self.level = self.originalLevel
            self.setupPreview()
            return

        oldshape = self.originalLevel.Blocks.shape
        blocks = self.originalLevel.Blocks
        data = self.originalLevel.Data

        roundedShape = oldshape

        newshape = map(lambda x: int(x * factor), oldshape)
        for i, part in enumerate(newshape):
            if part == 0:
                newshape[i] = 1
        xyzshape = newshape[0], newshape[2], newshape[1]
        newlevel = pymclevel.MCSchematic(xyzshape,
                                         mats=self.editor.level.materials)

        srcgrid = numpy.mgrid[0:roundedShape[0]:1.0 / factor,
                              0:roundedShape[1]:1.0 / factor,
                              0:roundedShape[2]:1.0 / factor].astype('uint')
        dstgrid = numpy.mgrid[0:newshape[0], 0:newshape[1],
                              0:newshape[2]].astype('uint')
        srcgrid = srcgrid[map(slice, dstgrid.shape)]
        dstgrid = dstgrid[map(slice, srcgrid.shape)]

        def copyArray(dest, src):
            dest[dstgrid[0], dstgrid[1],
                 dstgrid[2]] = src[srcgrid[0], srcgrid[1], srcgrid[2]]

        copyArray(newlevel.Blocks, blocks)
        copyArray(newlevel.Data, data)

        self.level = newlevel
        self.setupPreview()
Exemplo n.º 5
0
"""
Holds all the char set schematics.
"""
import pymclevel
from pkg_resources import resource_filename
from cbac.schematics.common import RESOURCE_MODULE

AZ_CAPS = pymclevel.MCSchematic(filename=resource_filename(RESOURCE_MODULE, 'az_caps.schematic'))
AZ_CAPS_COMPRESSED = pymclevel.MCSchematic(filename=resource_filename(RESOURCE_MODULE, 'az_caps_compressed.schematic'))
ASCII = pymclevel.MCSchematic(filename=resource_filename(RESOURCE_MODULE, 'ascii.schematic'))