Create RegionSets via the World object
This commit is contained in:
@@ -277,16 +277,22 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
||||
if not os.path.exists(destdir):
|
||||
os.mkdir(destdir)
|
||||
|
||||
# saves us from creating the same World object over and over again
|
||||
worldcache = {}
|
||||
|
||||
for render_name in render_things:
|
||||
render = render_things[render_name]
|
||||
logging.debug("Found the following render thing: %r", render)
|
||||
|
||||
# XXX we now construct the regionset directly
|
||||
#w = world.World(render['worldpath'])
|
||||
if (render['worldname'] not in worldcache):
|
||||
w = world.World(render['worldname'])
|
||||
worldcache[render['worldname']] = w
|
||||
else:
|
||||
w = worldcache[render['worldname']]
|
||||
|
||||
# if no dimension has been specified, just use the first one
|
||||
# TODO support the case where a different dimension is specified
|
||||
rset = world.RegionSet(render['worldname'])
|
||||
|
||||
# TODO get the correct regionset based on render['dimension']
|
||||
rset = w.get_regionset(0)
|
||||
logging.debug("Using RegionSet %r", rset)
|
||||
|
||||
# create our TileSet from this RegionSet
|
||||
|
||||
@@ -263,10 +263,6 @@ class MultiWorldParser(object):
|
||||
|
||||
def validate(self):
|
||||
|
||||
# first validate the world dict
|
||||
for worldname in self.world:
|
||||
if not os.path.exists(self.world[worldname]):
|
||||
raise Exception("%r does not exist for %s" % (self.world[worldname], worldname))
|
||||
|
||||
origs = dict()
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ from settingsValidators import *
|
||||
|
||||
render = {
|
||||
"worldname": dict(required=True, validator=validateWorldPath, save_orig=True),
|
||||
"dimension": dict(required=False, validator=validateDimension, default="default"),
|
||||
"title": dict(required=True, validator=validateStr),
|
||||
"rendermode": dict(required=False, validator=validateRenderMode),
|
||||
"northdirection": dict(required=False, validator=validateNorthDirection),
|
||||
|
||||
@@ -9,7 +9,10 @@ def validateWorldPath(name, **kwargs):
|
||||
world = kwargs.get('world', dict())
|
||||
if name not in world.keys():
|
||||
raise ValidationException("bad world name")
|
||||
return os.path.abspath(world[name])
|
||||
abs_path = os.path.abspath(world[name])
|
||||
if not os.path.exists(os.path.join(abs_path, "level.dat")):
|
||||
raise ValidationException("No level.dat file in %r. Check the path for world %r" % (abs_path, name))
|
||||
return abs_path
|
||||
|
||||
|
||||
def validateRenderMode(mode, **kwargs):
|
||||
@@ -94,3 +97,9 @@ def validateInt(i, **kwargs):
|
||||
|
||||
def validateStr(s, **kwargs):
|
||||
return str(s)
|
||||
|
||||
def validateDimension(d, **kwargs):
|
||||
if d in ["nether", "overworld", "end", "default"]:
|
||||
return d
|
||||
raise ValidationException("%r is not a valid dimension" % d)
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ class World(object):
|
||||
mcrs = filter(lambda x: x.endswith(".mcr"), files)
|
||||
if mcrs:
|
||||
# construct a regionset object for this
|
||||
rset = RegionSet(self, root)
|
||||
rset = RegionSet(root)
|
||||
if root == os.path.join(self.worlddir, "region"):
|
||||
self.regionsets.insert(0, rset)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user