def check_region(region_filename): chunk_errors = [] if not os.path.exists(region_filename): raise Exception('Region file not found: %s' % region_filename) try: region = nbt.load_region(region_filename) except IOError, e: raise Exception('Error loading region (%s): %s' % (region_filename, e))
options, args = parser.parse_args() if not options.world or not options.ids: parser.print_help() sys.exit(1) if not os.path.exists(options.world): raise Exception("%s does not exist" % options.world) ids = map(lambda x: int(x),options.ids.split(",")) sys.stderr.write("Searching for these blocks: %r...\n" % ids) matcher = re.compile(r"^r\..*\.mcr$") for dirpath, dirnames, filenames in os.walk(options.world): for f in filenames: if matcher.match(f): full = os.path.join(dirpath, f) r = nbt.load_region(full) chunks = r.get_chunks() for x,y in chunks: chunk = r.load_chunk(x,y).read_all() blocks = get_blockarray(chunk[1]['Level']) for i in ids: if i in blocks: print full break
if len(sys.argv) == 3: outdir = sys.argv[2] else: outdir = worlddir matcher = re.compile(r"^r\..*\.mcr$") POI = [] numsigns = 0 for dirpath, dirnames, filenames in os.walk(worlddir): for f in filenames: if matcher.match(f): #print f full = os.path.join(dirpath, f) r = nbt.load_region(full) chunks = r.get_chunks() for x, y in chunks: chunk = r.load_chunk(x, y).read_all() data = chunk[1]['Level']['TileEntities'] for entity in data: if entity['id'] == 'Sign': msg = ' \n'.join([ entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4'] ]) #print "checking -->%s<--" % msg.strip() if msg.strip(): newPOI = dict( type="sign", x=entity['x'],