示例#1
0
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, 'lower-left')
    except IOError, e:
        raise Exception('Error loading region (%s): %s' % (region_filename, e))
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, 'lower-left')
    except IOError, e:
        raise Exception('Error loading region (%s): %s' % (region_filename, e))
if os.path.exists(outputdir):
    print "Output directory is ", outputdir
else:
    sys.exit("Bad OutputDir")

matcher = re.compile(r"^r\..*\.mcr$")

POI = []

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'],
                                            y= entity['y'],
                                            z= entity['z'],
                                            msg=msg,
                                            chunk= (entity['x']/16, entity['z']/16),
if os.path.exists(outputdir):
    print "Output directory is ", outputdir
else:
    sys.exit("Bad OutputDir")

matcher = re.compile(r"^r\..*\.mcr$")

POI = []

for dirpath, dirnames, filenames in os.walk(worlddir):
    for f in filenames:
        if matcher.match(f):
            print f
            full = os.path.join(dirpath, f)
            # force lower-left so chunks are loaded in correct positions
            r = nbt.load_region(full, 'lower-left')
            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'],
                                            y= entity['y'],
                                            z= entity['z'],
                                            msg=msg,
                                            chunk= (entity['x']/16, entity['z']/16),
示例#5
0
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, 'lower-left')
            chunks = r.get_chunks()
            found = False
            for x, y in chunks:
                chunk = r.load_chunk(x, y).read_all()
                blocks = get_blockarray(chunk[1]['Level'])
                for i in ids:
                    if chr(i) in blocks:
                        print full
                        found = True
                        break
                if found:
                    break