Updated findSigns.py & rerenderBlocks.py to work against region format
This commit is contained in:
8
chunk.py
8
chunk.py
@@ -73,10 +73,10 @@ def get_blockarray(level):
|
|||||||
Block array, which just contains all the block ids"""
|
Block array, which just contains all the block ids"""
|
||||||
return numpy.frombuffer(level['Blocks'], dtype=numpy.uint8).reshape((16,16,128))
|
return numpy.frombuffer(level['Blocks'], dtype=numpy.uint8).reshape((16,16,128))
|
||||||
|
|
||||||
def get_blockarray_fromfile(world,filename):
|
def get_blockarray_fromfile(filename):
|
||||||
"""Same as get_blockarray except takes a filename and uses get_lvldata to
|
"""Same as get_blockarray except takes a filename. This is a shortcut"""
|
||||||
open it. This is a shortcut"""
|
d = nbt.load_from_region(filename, x, y)
|
||||||
level = get_lvldata(world,filename)
|
level = return d[1]['Level']
|
||||||
return get_blockarray(level)
|
return get_blockarray(level)
|
||||||
|
|
||||||
def get_skylight_array(level):
|
def get_skylight_array(level):
|
||||||
|
|||||||
@@ -33,30 +33,34 @@ if os.path.exists(worlddir):
|
|||||||
else:
|
else:
|
||||||
sys.exit("Bad WorldDir")
|
sys.exit("Bad WorldDir")
|
||||||
|
|
||||||
matcher = re.compile(r"^c\..*\.dat$")
|
matcher = re.compile(r"^r\..*\.mcr$")
|
||||||
|
|
||||||
POI = []
|
POI = []
|
||||||
|
|
||||||
for dirpath, dirnames, filenames in os.walk(worlddir):
|
for dirpath, dirnames, filenames in os.walk(worlddir):
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
if matcher.match(f):
|
if matcher.match(f):
|
||||||
|
print f
|
||||||
full = os.path.join(dirpath, f)
|
full = os.path.join(dirpath, f)
|
||||||
#print "inspecting %s" % full
|
r = nbt.load_region(full)
|
||||||
data = nbt.load(full)[1]['Level']['TileEntities']
|
chunks = r.get_chunks()
|
||||||
for entity in data:
|
for x,y in chunks:
|
||||||
if entity['id'] == 'Sign':
|
chunk = r.load_chunk(x,y).read_all()
|
||||||
msg=' \n'.join([entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']])
|
data = chunk[1]['Level']['TileEntities']
|
||||||
#print "checking -->%s<--" % msg.strip()
|
for entity in data:
|
||||||
if msg.strip():
|
if entity['id'] == 'Sign':
|
||||||
newPOI = dict(type="sign",
|
msg=' \n'.join([entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']])
|
||||||
x= entity['x'],
|
#print "checking -->%s<--" % msg.strip()
|
||||||
y= entity['y'],
|
if msg.strip():
|
||||||
z= entity['z'],
|
newPOI = dict(type="sign",
|
||||||
msg=msg,
|
x= entity['x'],
|
||||||
chunk= (entity['x']/16, entity['z']/16),
|
y= entity['y'],
|
||||||
)
|
z= entity['z'],
|
||||||
POI.append(newPOI)
|
msg=msg,
|
||||||
print "Found sign at (%d, %d, %d): %r" % (newPOI['x'], newPOI['y'], newPOI['z'], newPOI['msg'])
|
chunk= (entity['x']/16, entity['z']/16),
|
||||||
|
)
|
||||||
|
POI.append(newPOI)
|
||||||
|
print "Found sign at (%d, %d, %d): %r" % (newPOI['x'], newPOI['y'], newPOI['z'], newPOI['msg'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ blockID. The output is a chunklist file that is suitable to use with the
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
python contrib/rerenderBlocks.py --ids=46,79,91 --world=world/> chunklist.txt
|
python contrib/rerenderBlocks.py --ids=46,79,91 --world=world/> regionlist.txt
|
||||||
python overviewer.py --chunklist=chunklist.txt world/ output_dir/
|
python overviewer.py --regionlist=regionlist.txt world/ output_dir/
|
||||||
|
|
||||||
This will rerender any chunks that contain either TNT (46), Ice (79), or
|
This will rerender any chunks that contain either TNT (46), Ice (79), or
|
||||||
a Jack-O-Lantern (91)
|
a Jack-O-Lantern (91)
|
||||||
@@ -42,15 +42,20 @@ ids = map(lambda x: int(x),options.ids.split(","))
|
|||||||
sys.stderr.write("Searching for these blocks: %r...\n" % ids)
|
sys.stderr.write("Searching for these blocks: %r...\n" % ids)
|
||||||
|
|
||||||
|
|
||||||
matcher = re.compile(r"^c\..*\.dat$")
|
matcher = re.compile(r"^r\..*\.mcr$")
|
||||||
|
|
||||||
for dirpath, dirnames, filenames in os.walk(options.world):
|
for dirpath, dirnames, filenames in os.walk(options.world):
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
if matcher.match(f):
|
if matcher.match(f):
|
||||||
full = os.path.join(dirpath, f)
|
full = os.path.join(dirpath, f)
|
||||||
blocks = get_blockarray_fromfile(full)
|
r = nbt.load_region(full)
|
||||||
for i in ids:
|
chunks = r.get_chunks()
|
||||||
if i in blocks:
|
for x,y in chunks:
|
||||||
print full
|
chunk = r.load_chunk(x,y).read_all()
|
||||||
break
|
blocks = get_blockarray(chunk[1]['Level'])
|
||||||
|
for i in ids:
|
||||||
|
if i in blocks:
|
||||||
|
print full
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user