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)
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()
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()
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)
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
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()
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])
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
def test_session_lock(self): temp = TempLevel("AnvilWorld") level = temp.level def touch(): level.saveInPlace() self.assertRaises(SessionLockLost, touch)
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)
def test_session_lock(self): temp = TempLevel("AnvilWorld") level = temp.level level2 = MCInfdevOldLevel(level.filename) def touch(): level.saveInPlace() self.assertRaises(SessionLockLost, touch)
def test_session_lock(self): temp = TempLevel("AnvilWorld") level = temp level2 = WorldEditor(level.filename, resume=False) def touch(): level.saveChanges() self.assertRaises(SessionLockLost, touch)
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
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()
def setUp(self): self.srclevel = TempLevel("hell.mclevel") self.indevlevel = TempLevel("hueg.mclevel")
def setUp(self): self.creativelevel = TempLevel("Dojo_64_64_128.dat") self.indevlevel = TempLevel("hell.mclevel")
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
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
def testPrimordialDesert(): templevel = TempLevel("PrimordialDesert") level = templevel.level for chunk in level.allChunks: level.getChunk(*chunk)
def setUp(self): self.indevLevel = TempLevel("hell.mclevel") self.anvilLevel = TempLevel("PyTestWorld")
def sourceLevel(): return TempLevel("Station.schematic")
def anvilLevel(): return TempLevel("AnvilWorld")
def setUp(self): # self.alphaLevel = TempLevel("Dojo_64_64_128.dat") self.schematicLevel = TempLevel("Floating.schematic") self.anvilLevel = TempLevel("AnvilWorld")
def sourceLevel(request): return TempLevel(request.param)
def setUp(self): # self.alphaLevel = TempLevel("Dojo_64_64_128.dat") self.indevLevel = TempLevel("hell.mclevel") self.anvilLevel = TempLevel("AnvilWorld")
def setUp(self): # self.alphaLevel = TempLevel("Dojo_64_64_128.dat") self.level = TempLevel("PocketWorld") self.alphalevel = TempLevel("AnvilWorld")
def timeFill(): temp = TempLevel("AnvilWorld") editor = temp dim = editor.getDimension() editor.loadedChunkLimit = 1 exhaust(dim.fillBlocksIter(dim.bounds, editor.blocktypes.OakWoodPlanks))
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