コード例 #1
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)
コード例 #2
0
ファイル: relight_test.py プロジェクト: nkjcqvcpi/mcedit2
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()
コード例 #3
0
def testExport():
    level = alpha_test_level()

    for size in [(16, 16, 16),
                 (15, 16, 16),
                 (15, 16, 15),
                 (15, 15, 15),
    ]:
        schem = level.extractSchematic(BoundingBox((0, 0, 0), size))
        schem = TempLevel("schem", createFunc=lambda f: schem.saveToFile(f)).level
        assert (schem.Blocks > 255).any()
コード例 #4
0
def world(request):
    if request.param == "PocketWorldAdapter.zip":

        def unpackPocket(tmpname):
            zf = zipfile.ZipFile("test_files/PocketWorldAdapter.zip")
            zf.extractall(tmpname)
            return WorldEditor(tmpname + "/PocketWorldAdapter")

        return TempLevel("XXX", createFunc=unpackPocket)

    return TempLevel(request.param)
コード例 #5
0
def alpha_test_level():
    level = TempLevel("alpha", createFunc=lambda f: WorldEditor(f, create=True))
    level.createChunk(0, 0)

    for x in range(0, 10):
        level.setBlockID(x, 2, 5, 2048)

    level.saveChanges()
    level.close()

    level = WorldEditor(filename=level.filename)
    return level
コード例 #6
0
def testExport():
    level = alpha_test_level()

    for size in [
        (15, 15, 15),
        (16, 16, 16),
        (15, 16, 16),
        (15, 16, 15),
    ]:
        schem = extractSchematicFrom(level, BoundingBox((0, 0, 0), size))
        schem = TempLevel("schem", createFunc=lambda f: schem.saveToFile(f))
        assert (schem.Blocks > 255).any()
コード例 #7
0
def test_command_block():
    level = TempLevel("AnvilWorld").level

    cmdblock = fromFile("testfiles/Commandblock.schematic")

    point = level.bounds.origin + [p/2 for p in level.bounds.size]
    level.copyBlocksFrom(cmdblock, cmdblock.bounds, point)

    te = level.tileEntityAt(*point)
    command = te['Command'].value
    words = command.split(' ')
    x, y, z = words[2:5]
    assert x == str(point[0])
    assert y == str(point[1] + 10)
    assert z == str(point[2])
コード例 #8
0
    def testSave(self):

        level = self.testCreate()
        level["Environment"]["SurroundingWaterHeight"].value += 6

        # Save the entire TAG structure to a different file.
        TempLevel("atlantis.mclevel", createFunc=level.save)  # xxx don't use templevel here
コード例 #9
0
    def test_session_lock(self):
        temp = TempLevel("AnvilWorld")
        level = temp.level

        def touch():
            level.saveInPlace()

        self.assertRaises(SessionLockLost, touch)
コード例 #10
0
    def testCreate(self):
        gen = MCServerChunkGenerator()
        print "Version: ", gen.serverVersion

        def _testCreate(filename):
            gen.createLevel(filename, BoundingBox((-128, 0, -128), (128, 128, 128)))

        TempLevel("ServerCreate", createFunc=_testCreate)
コード例 #11
0
    def test_session_lock(self):
        temp = TempLevel("AnvilWorld")
        level = temp.level
        level2 = MCInfdevOldLevel(level.filename)

        def touch():
            level.saveInPlace()

        self.assertRaises(SessionLockLost, touch)
コード例 #12
0
    def test_session_lock(self):
        temp = TempLevel("AnvilWorld")
        level = temp
        level2 = WorldEditor(level.filename, resume=False)

        def touch():
            level.saveChanges()

        self.assertRaises(SessionLockLost, touch)
コード例 #13
0
def alpha_test_level():
    temp = TempLevel("alpha",
                     createFunc=lambda f: MCInfdevOldLevel(f, create=True))
    level = temp.level
    level.createChunk(0, 0)

    for x in range(0, 10):
        level.setBlockAt(x, 2, 5, 2048)

    level.saveInPlace()
    level.close()

    level = MCInfdevOldLevel(filename=level.filename)
    return level
コード例 #14
0
def test_relight():
    templevel = TempLevel("AnvilWorld")
    anvilLevel = templevel
    anvilDim = anvilLevel.getDimension()
    bounds = anvilDim.bounds
    point = bounds.origin + (bounds.size * (0.5, 0.5, 0.5))

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

    #    box = BoundingBox((256, 0, 256), (64, anvilLevel.Height, 64))
    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)

    #anvilLevel = WorldEditor(filename=temppath, create=True)
    station = WorldEditor("test_files/station.schematic")
    stationDim = station.getDimension()
    anvilDim.copyBlocks(stationDim, stationDim.bounds, point, create=True)
    for cPos in anvilDim.chunkPositions():
        anvilDim.getChunk(*cPos)

    #anvilLevel.copyBlocksFrom(station, station.bounds, point + (station.Width, 0, 0), create=True)
    anvilLevel.generateLights()

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

    # os.system(sys.executable + " ../mcedit.py " + anvilLevel.filename)

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

    check()

    anvilLevel.close()

    anvilLevel = WorldEditor(templevel.tmpname)
    check()
コード例 #15
0
ファイル: indev_test.py プロジェクト: Verkhovskaya/DreamCraft
 def setUp(self):
     self.srclevel = TempLevel("hell.mclevel")
     self.indevlevel = TempLevel("hueg.mclevel")
コード例 #16
0
 def setUp(self):
     self.creativelevel = TempLevel("Dojo_64_64_128.dat")
     self.indevlevel = TempLevel("hell.mclevel")
コード例 #17
0
def test_schematic_extended_ids():
    s = SchematicFile(shape=(1, 1, 5))
    s.Blocks[0, 0, 0] = 2048
    temp = TempLevel("schematic", createFunc=s.saveToFile)
    s = temp
    assert s.Blocks[0, 0, 0] == 2048
コード例 #18
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
コード例 #19
0
def alpha_test_level():
    level = TempLevel("alpha",
                      createFunc=lambda f: WorldEditor(f, create=True))
    level.createChunk(0, 0)

    for x in range(0, 10):
        level.setBlockID(x, 2, 5, 2048)

    level.saveChanges()
    level.close()

    level = WorldEditor(filename=level.filename)
    return level
コード例 #20
0
def testPrimordialDesert():
    templevel = TempLevel("PrimordialDesert")
    level = templevel.level
    for chunk in level.allChunks:
        level.getChunk(*chunk)
コード例 #21
0
ファイル: mcr_test.py プロジェクト: Verkhovskaya/DreamCraft
 def setUp(self):
     self.indevLevel = TempLevel("hell.mclevel")
     self.anvilLevel = TempLevel("PyTestWorld")
コード例 #22
0
ファイル: anvil_test.py プロジェクト: metehanboy/mcedit2
def sourceLevel():
    return TempLevel("Station.schematic")
コード例 #23
0
ファイル: anvil_test.py プロジェクト: metehanboy/mcedit2
def anvilLevel():
    return TempLevel("AnvilWorld")
コード例 #24
0
 def setUp(self):
     # self.alphaLevel = TempLevel("Dojo_64_64_128.dat")
     self.schematicLevel = TempLevel("Floating.schematic")
     self.anvilLevel = TempLevel("AnvilWorld")
コード例 #25
0
def sourceLevel(request):
    return TempLevel(request.param)
コード例 #26
0
 def setUp(self):
     # self.alphaLevel = TempLevel("Dojo_64_64_128.dat")
     self.indevLevel = TempLevel("hell.mclevel")
     self.anvilLevel = TempLevel("AnvilWorld")
コード例 #27
0
 def setUp(self):
     # self.alphaLevel = TempLevel("Dojo_64_64_128.dat")
     self.level = TempLevel("PocketWorld")
     self.alphalevel = TempLevel("AnvilWorld")
コード例 #28
0
def timeFill():
    temp = TempLevel("AnvilWorld")
    editor = temp
    dim = editor.getDimension()
    editor.loadedChunkLimit = 1
    exhaust(dim.fillBlocksIter(dim.bounds, editor.blocktypes.OakWoodPlanks))
コード例 #29
0
import numpy
from templevel import TempLevel
from mceditlib.selection import BoundingBox

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


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


def timeGetBlocksFast():

    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]

    print "Coords", [x, y, z], "maxz", z.max()
    print "Length", level.getBlocks(x, y, z, return_Data=True).Blocks.shape


def timeGetBlocks():

    x, y, z = numpy.transpose(list(box.positions))

    print "Coords", [x, y, z], "maxz", z.max()
    print "Length", level.getBlocks(x, y, z, return_Data=True).Blocks.shape
コード例 #30
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()