Exemplo n.º 1
0
def test_relight():
    pc_world = TempLevel("AnvilWorld")
    anvilDim = pc_world.getDimension()
    bounds = anvilDim.bounds
    point = bounds.origin + (bounds.size * (0.5, 0.5, 0.5))

    box = bounds.expand(-100, 0, -100)

    chunks = [(cx, cz) for cx, cz in anvilDim.chunkPositions() if (cx << 4, 1, cz << 4) not in box]
    for c in chunks:
        anvilDim.deleteChunk(*c)

    station = TempLevel("station.schematic")
    stationDim = station.getDimension()
    anvilDim.copyBlocks(stationDim, stationDim.bounds, point, create=True)

    pc_world.saveChanges()
    cx = int(point.x + 32) >> 4
    cz = int(point.z + 32) >> 4

    def check():
        sl = numpy.sum(pc_world.getChunk(cx, cz).SkyLight)
        bl = numpy.sum(pc_world.getChunk(cx, cz).BlockLight)
        assert (sl, bl) == (341328, 43213)

    check()

    pc_world.close()

    pc_world = WorldEditor(templevel.tmpname)
    check()
Exemplo n.º 2
0
def test_relight():
    pc_world = TempLevel("AnvilWorld")
    anvilDim = pc_world.getDimension()
    bounds = anvilDim.bounds
    point = bounds.origin + (bounds.size * (0.5, 0.5, 0.5))

    box = bounds.expand(-100, 0, -100)

    chunks = [(cx, cz) for cx, cz in anvilDim.chunkPositions()
              if (cx << 4, 1, cz << 4) not in box]
    for c in chunks:
        anvilDim.deleteChunk(*c)

    station = TempLevel("station.schematic")
    stationDim = station.getDimension()
    anvilDim.copyBlocks(stationDim, stationDim.bounds, point, create=True)

    pc_world.saveChanges()
    cx = int(point.x + 32) >> 4
    cz = int(point.z + 32) >> 4

    def check():
        sl = numpy.sum(pc_world.getChunk(cx, cz).SkyLight)
        bl = numpy.sum(pc_world.getChunk(cx, cz).BlockLight)
        assert (sl, bl) == (341328, 43213)

    check()

    pc_world.close()

    pc_world = WorldEditor(templevel.tmpname)
    check()
Exemplo n.º 3
0
    def testCopyOffsets(self):
        editor = TempLevel("AnvilWorld")
        dimension = editor.getDimension()
        schematic = createSchematic((13, 8, 5))
        schematicDim = schematic.getDimension()

        x, y, z = dimension.bounds.origin + [p/2 for p in dimension.bounds.size]
        for dx in range(16):
            for dz in range(16):
                dimension.copyBlocks(schematicDim, schematicDim.bounds, (x+dx, y, z+dz), biomes=True)
Exemplo n.º 4
0
import numpy
from templevel import TempLevel
from mceditlib.selection import BoundingBox

level = TempLevel("AnvilWorld")
dim = level.getDimension()
box = BoundingBox(dim.bounds.origin, (64, 32, 64))

def timeGetBlocksOld():
    for x, y, z in box.positions:
        dim.getBlockID(x, y, z)
        dim.getBlockData(x, y, z)

def timeSetBlocksOld():
    for x, y, z in box.positions:
        dim.setBlockID(x, y, z, 1)
        dim.setBlockData(x, y, z, 1)


def timeGetBlocksGrid():
    x, y, z = numpy.mgrid[
              box.minx:box.maxx,
              box.miny:box.maxy,
              box.minz:box.maxz,
    ]

    x, y, z = [numpy.ravel(a) for a in x, y, z]
    result = dim.getBlocks(x, y, z, return_Data=True)
    #print "Coords", [x, y, z], "maxz", z.max()
    #print "Length", result.Blocks.shape