From d0267d4e7863e72f93dcb91ff7a3e199bb1eafbe Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Mon, 8 Nov 2010 20:38:27 -0500 Subject: [PATCH] new contrib script to help re-rendering specific parts of a map See the top of the file for usage details --- contrib/rerenderBlocks.py | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 contrib/rerenderBlocks.py diff --git a/contrib/rerenderBlocks.py b/contrib/rerenderBlocks.py new file mode 100644 index 0000000..19ab178 --- /dev/null +++ b/contrib/rerenderBlocks.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +''' +This is used to force the regeneration of any chunks that contain a certain +blockID. The output is a chunklist file that is suitable to use with the +--chunklist option to gmap.py. + +Example: + +python contrib/rerenderBlocks.py --ids=46,79,91 --world=world/> chunklist.txt + python gmap.py --chunklist=chunklist.txt world/ output_dir/ + +This will rerender any chunks that contain either TNT (46), Ice (79), or +a Jack-O-Lantern (91) +''' + +from optparse import OptionParser + +import sys +sys.path.insert(0,".") + +import nbt +from chunk import get_blockarray_fromfile +import os +import re + +parser = OptionParser() +parser.add_option("--ids", dest="ids", type="string") +parser.add_option("--world", dest="world", type="string") + + +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"^c\..*\.dat$") + +for dirpath, dirnames, filenames in os.walk(options.world): + for f in filenames: + if matcher.match(f): + full = os.path.join(dirpath, f) + blocks = get_blockarray_fromfile(full) + for i in ids: + if i in blocks: + print full + break +