Merge remote-tracking branch 'origin/rewrite' into anvil
This commit is contained in:
@@ -73,6 +73,7 @@ renders = Setting(required=True, default={},
|
||||
"texturepath": Setting(required=False, validator=validateTexturePath, default=None),
|
||||
"renderchecks": Setting(required=False, validator=validateInt, default=None),
|
||||
"rerenderprob": Setting(required=True, validator=validateFloat, default=0),
|
||||
"crop": Setting(required=False, validator=validateCrop, default=None),
|
||||
|
||||
# Remove this eventually (once people update their configs)
|
||||
"worldname": Setting(required=False, default=None,
|
||||
|
||||
@@ -166,6 +166,16 @@ def validateOutputDir(d):
|
||||
raise ValidationException("You must specify a valid output directory")
|
||||
return os.path.abspath(d)
|
||||
|
||||
def validateCrop(value):
|
||||
if len(value) != 4:
|
||||
raise ValidationException("The value for the 'crop' setting must be a tuple of length 4")
|
||||
value = tuple(int(x) for x in value)
|
||||
if value[0] >= value[2]:
|
||||
raise ValidationException("About your crop numbers, the xmax value must be greater than the xmin value")
|
||||
if value[1] >= value[3]:
|
||||
raise ValidationException("About your crop numbers, the zmax value must be greater than the zmin value")
|
||||
return value
|
||||
|
||||
def make_dictValidator(keyvalidator, valuevalidator):
|
||||
"""Compose and return a dict validator -- a validator that validates each
|
||||
key and value in a dictionary.
|
||||
|
||||
@@ -490,7 +490,7 @@ class TileSet(object):
|
||||
bounds = self._find_chunk_range()
|
||||
|
||||
# Calculate the depth of the tree
|
||||
for p in xrange(1,33): # max 32
|
||||
for p in xrange(2,33): # max 32
|
||||
# Will 2^p tiles wide and high suffice?
|
||||
|
||||
# X has twice as many chunks as tiles, then halved since this is a
|
||||
@@ -499,8 +499,11 @@ class TileSet(object):
|
||||
# Y has 4 times as many chunks as tiles, then halved since this is
|
||||
# a radius
|
||||
yradius = 2*2**p
|
||||
# The +32 on the y bounds is because chunks are very tall, and in
|
||||
# rare cases when the bottom of the map is close to a border, it
|
||||
# could get cut off
|
||||
if xradius >= bounds.maxcol and -xradius <= bounds.mincol and \
|
||||
yradius >= bounds.maxrow and -yradius <= bounds.minrow:
|
||||
yradius >= bounds.maxrow + 32 and -yradius <= bounds.minrow:
|
||||
break
|
||||
self.treedepth = p
|
||||
self.xradius = xradius
|
||||
|
||||
@@ -512,6 +512,40 @@ class RotatedRegionSet(RegionSetWrapper):
|
||||
x,z = self.rotate(x,z)
|
||||
yield x,z,mtime
|
||||
|
||||
class CroppedRegionSet(RegionSetWrapper):
|
||||
def __init__(self, rsetobj, xmin, zmin, xmax, zmax):
|
||||
super(CroppedRegionSet, self).__init__(rsetobj)
|
||||
self.xmin = xmin//16
|
||||
self.xmax = xmax//16
|
||||
self.zmin = zmin//16
|
||||
self.zmax = zmax//16
|
||||
|
||||
def get_chunk(self,x,z):
|
||||
if (
|
||||
self.xmin <= x <= self.xmax and
|
||||
self.zmin <= z <= self.zmax
|
||||
):
|
||||
return super(CroppedRegionSet, self).get_chunk(x,z)
|
||||
else:
|
||||
raise ChunkDoesntExist("This chunk is out of the requested bounds")
|
||||
|
||||
def iterate_chunks(self):
|
||||
return ((x,z,mtime) for (x,z,mtime) in super(CroppedRegionSet,self).iterate_chunks()
|
||||
if
|
||||
self.xmin <= x <= self.xmax and
|
||||
self.zmin <= z <= self.zmax
|
||||
)
|
||||
def get_chunk_mtime(self,x,z):
|
||||
if (
|
||||
self.xmin <= x <= self.xmax and
|
||||
self.zmin <= z <= self.zmax
|
||||
):
|
||||
return super(CroppedRegionSet, self).get_chunk_mtime(x,z)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def get_save_dir():
|
||||
"""Returns the path to the local saves directory
|
||||
* On Windows, at %APPDATA%/.minecraft/saves/
|
||||
|
||||
Reference in New Issue
Block a user