def main(): # sotre the altitude frequency array for each block_id res = defaultdict(lambda: [0] * 256) world = pymclevel.loadWorld("C:\\Users\\tolomea\\AppData\\Roaming\\.minecraft2\\saves\\New World-") for i, chunk_loc in enumerate(world.allChunks): print i, chunk_loc chunk = world.getChunk(*chunk_loc) blocks = chunk.Blocks.reshape((256, 256)) # flatten horizontal position data = chunk.Data.reshape((256, 256)) # flatten horizontal position for key in block_ids: block_id, subblock_id, name = key mask = blocks == block_id if subblock_id is not None: mask &= data == subblock_id res[key] += mask.sum(0) body = [] for key in block_ids: column = list(key) + list(res[key]) body.append(column) body = zip(*body) with open("dump.csv", "wb") as csvfile: writer = csv.writer(csvfile, delimiter=",") for r in body: print r writer.writerow(r)
def load_world(name): import pymclevel # takes a long time, so only imported after argparse if isinstance(name, pymclevel.MCLevel): return name try: if osp.isfile(name): return pymclevel.fromFile(name) else: return pymclevel.loadWorld(name) except IOError as e: raise PyMCLevelError(e) except pymclevel.mclevel.LoadingError: raise PyMCLevelError("Not a valid Minecraft world: '%s'" % name)
def load_world(name): import pymclevel if isinstance(name, pymclevel.MCLevel): return name try: if osp.isfile(name): return pymclevel.fromFile(name) else: return pymclevel.loadWorld(name) except IOError as e: raise MCError(e) except pymclevel.mclevel.LoadingError: raise MCError("Not a valid Minecraft world: '%s'" % name)