def testCreate(self): # log.info("Schematic from indev") size = (64, 64, 64) temp = mktemp("testcreate.schematic") schematic = MCSchematic(shape=size, filename=temp, mats='Classic') level = self.indevLevel.level schematic.copyBlocksFrom(level, BoundingBox((0, 0, 0), (64, 64, 64,)), (0, 0, 0)) assert((schematic.Blocks[0:64, 0:64, 0:64] == level.Blocks[0:64, 0:64, 0:64]).all()) schematic.copyBlocksFrom(level, BoundingBox((0, 0, 0), (64, 64, 64,)), (-32, -32, -32)) assert((schematic.Blocks[0:32, 0:32, 0:32] == level.Blocks[32:64, 32:64, 32:64]).all()) schematic.saveInPlace() schem = mclevel.fromFile("schematics/CreativeInABox.schematic") tempSchematic = MCSchematic(shape=(1, 1, 3)) tempSchematic.copyBlocksFrom(schem, BoundingBox((0, 0, 0), (1, 1, 3)), (0, 0, 0)) level = self.anvilLevel.level for cx, cz in itertools.product(xrange(0, 4), xrange(0, 4)): try: level.createChunk(cx, cz) except ValueError: pass schematic.copyBlocksFrom(level, BoundingBox((0, 0, 0), (64, 64, 64,)), (0, 0, 0)) schematic.close() os.remove(temp)
def testCreate(): temppath = mktemp("AnvilCreate") pc_world = WorldEditor(filename=temppath, create=True, adapterClass=AnvilWorldAdapter) pc_world.close() shutil.rmtree(temppath)
def testCreate(self): # log.info("Schematic from indev") size = (64, 64, 64) temp = mktemp("testcreate.schematic") editor = createSchematic(shape=size, blocktypes='Classic') editor.filename = temp dim = editor.getDimension() level = self.schematicLevel dim.importSchematic(level, (0, 0, 0)) assert((schematic.Blocks[0:64, 0:64, 0:64] == level.adapter.Blocks[0:64, 0:64, 0:64]).all()) dim.importSchematic(level, (-32, -32, -32)) assert((schematic.Blocks[0:32, 0:32, 0:32] == level.adapter.Blocks[32:64, 32:64, 32:64]).all()) schematic.saveChanges() schem = WorldEditor("test_files/Station.schematic") tempEditor = createSchematic(shape=(1, 1, 3)) tempDim = tempEditor.getDimension() tempDim.copyBlocks(schem, BoundingBox((0, 0, 0), (1, 1, 3)), (0, 0, 0)) level = self.pc_world for cx, cz in itertools.product(xrange(0, 4), xrange(0, 4)): try: level.createChunk(cx, cz) except ValueError: pass dim.copyBlocks(level.getDimension(), BoundingBox((0, 0, 0), (64, 64, 64,)), (0, 0, 0)) os.remove(temp)
def testCreate(self): # log.info("Schematic from indev") size = (64, 64, 64) temp = mktemp("testcreate.schematic") editor = createSchematic(shape=size, blocktypes='Classic') editor.filename = temp dim = editor.getDimension() level = self.schematicLevel dim.importSchematic(level, (0, 0, 0)) assert((schematic.Blocks[0:64, 0:64, 0:64] == level.adapter.Blocks[0:64, 0:64, 0:64]).all()) dim.importSchematic(level, (-32, -32, -32)) assert((schematic.Blocks[0:32, 0:32, 0:32] == level.adapter.Blocks[32:64, 32:64, 32:64]).all()) schematic.saveChanges() schem = WorldEditor("test_files/Station.schematic") tempEditor = createSchematic(shape=(1, 1, 3)) tempDim = tempEditor.getDimension() tempDim.copyBlocks(schem, BoundingBox((0, 0, 0), (1, 1, 3)), (0, 0, 0)) level = self.anvilLevel for cx, cz in itertools.product(xrange(0, 4), xrange(0, 4)): try: level.createChunk(cx, cz) except ValueError: pass dim.copyBlocks(level.getDimension(), BoundingBox((0, 0, 0), (64, 64, 64,)), (0, 0, 0)) os.remove(temp)
def testCreate(self): # log.info("Schematic from indev") size = (64, 64, 64) temp = mktemp("testcreate.schematic") schematic = MCSchematic(shape=size, filename=temp, mats='Classic') level = self.indevLevel.level schematic.copyBlocksFrom(level, BoundingBox((0, 0, 0), (64, 64, 64,)), (0, 0, 0)) assert ((schematic.Blocks[0:64, 0:64, 0:64] == level.Blocks[0:64, 0:64, 0:64]).all()) schematic.copyBlocksFrom(level, BoundingBox((0, 0, 0), (64, 64, 64,)), (-32, -32, -32)) assert ((schematic.Blocks[0:32, 0:32, 0:32] == level.Blocks[32:64, 32:64, 32:64]).all()) schematic.saveInPlace() schem = mclevel.fromFile("schematics/CreativeInABox.schematic") tempSchematic = MCSchematic(shape=(1, 1, 3)) tempSchematic.copyBlocksFrom(schem, BoundingBox((0, 0, 0), (1, 1, 3)), (0, 0, 0)) level = self.anvilLevel.level for cx, cz in itertools.product(xrange(0, 4), xrange(0, 4)): try: level.createChunk(cx, cz) except ValueError: pass schematic.copyBlocksFrom(level, BoundingBox((0, 0, 0), (64, 64, 64,)), (0, 0, 0)) schematic.close() os.remove(temp)
def testCopyChunks(self): level = self.anvilLevel.level temppath = mktemp("AnvilCreate") newLevel = MCInfdevOldLevel(filename=temppath, create=True) for cx, cz in level.allChunks: newLevel.copyChunkFrom(level, cx, cz) newLevel.close() shutil.rmtree(temppath)
def testBigEndianIntHeightMap(self): """ Test modifying, saving, and loading the new TAG_Int_Array heightmap added with the Anvil format. """ chunk = nbt.load("testfiles/AnvilChunk.dat") hm = chunk["Level"]["HeightMap"] hm.value[2] = 500 oldhm = numpy.array(hm.value) filename = mktemp("ChangedChunk") chunk.save(filename) changedChunk = nbt.load(filename) os.unlink(filename) eq = (changedChunk["Level"]["HeightMap"].value == oldhm) assert eq.all()
def testBigEndianIntHeightMap(): """ Test modifying, saving, and loading the new TAG_Int_Array heightmap added with the Anvil format. """ region = RegionFile(TempFile("AnvilWorld/region/r.0.0.mca")) chunk_data = region.readChunkBytes(0, 0) chunk = nbt.load(buf=chunk_data) hm = chunk["Level"]["HeightMap"] hm.value[2] = 500 oldhm = numpy.array(hm.value) filename = mktemp("ChangedChunk") chunk.save(filename) changedChunk = nbt.load(filename) os.unlink(filename) eq = (changedChunk["Level"]["HeightMap"].value == oldhm) assert eq.all()
def testCreate(self): temppath = mktemp("AnvilCreate") self.anvilLevel = MCInfdevOldLevel(filename=temppath, create=True) self.anvilLevel.close() shutil.rmtree(temppath)