0

Merge branch 'master' of git://github.com/brownan/Minecraft-Overviewer

This commit is contained in:
Andrew Chin
2011-03-07 19:11:11 -05:00
3 changed files with 204 additions and 203 deletions

View File

@@ -50,7 +50,12 @@ def get_lvldata(filename, x, y):
"""Takes a filename and chunkcoords and returns the Level struct, which contains all the
level info"""
try:
d = nbt.load_from_region(filename, x, y)
except Exception, e:
logging.warning("Error opening chunk (%i, %i) in %s. It may be corrupt. %s", x, y, filename, e)
raise ChunkCorrupt(str(e))
if not d: raise NoSuchChunk(x,y)
return d[1]['Level']
@@ -97,21 +102,6 @@ def get_tileentity_data(level):
data = level['TileEntities']
return data
def iterate_chunkblocks(xoff,yoff):
"""Iterates over the 16x16x128 blocks of a chunk in rendering order.
Yields (x,y,z,imgx,imgy)
x,y,z is the block coordinate in the chunk
imgx,imgy is the image offset in the chunk image where that block should go
"""
for x in xrange(15,-1,-1):
for y in xrange(16):
imgx = xoff + x*12 + y*12
imgy = yoff - x*6 + y*6 + 128*12 + 16*12//2
for z in xrange(128):
yield x,y,z,imgx,imgy
imgy -= 12
# This set holds blocks ids that can be seen through, for occlusion calculations
transparent_blocks = set([0, 6, 8, 9, 18, 20, 37, 38, 39, 40, 44, 50, 51, 52, 53, 55,
59, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 74, 75, 76, 77, 78, 79, 81, 83, 85])
@@ -266,11 +256,8 @@ class ChunkRenderer(object):
try:
self._level = get_lvldata(self.regionfile, self.chunkX, self.chunkY)
except NoSuchChunk, e:
#logging.debug("Skipping non-existant chunk")
logging.debug("Skipping non-existant chunk")
raise
except Exception, e:
logging.warning("Error opening chunk file %s. It may be corrupt. %s", self.regionfile, e)
raise ChunkCorrupt(str(e))
return self._level
level = property(_load_level)
@@ -689,7 +676,14 @@ class ChunkRenderer(object):
if not img:
img = Image.new("RGBA", (384, 1728), (38,92,255,0))
for x,y,z,imgx,imgy in iterate_chunkblocks(xoff,yoff):
for x in xrange(15,-1,-1):
for y in xrange(16):
imgx = xoff + x*12 + y*12
imgy = yoff - x*6 + y*6 + 128*12 + 16*12//2
imgy += 12
for z in xrange(128):
imgy -= 12
blockid = blocks[x,y,z]
# the following blocks don't have textures that can be pre-computed from the blockid

11
gmap.py
View File

@@ -71,6 +71,13 @@ def main():
if not os.path.exists(worlddir):
# world given is either world number, or name
worlds = world.get_worlds()
# if there are no worlds found at all, exit now
if not worlds:
parser.print_help()
print "\nInvalid world path"
sys.exit(1)
try:
worldnum = int(worlddir)
worlddir = worlds[worldnum]['path']
@@ -80,13 +87,13 @@ def main():
worlddir = worlds[worlddir]['path']
except KeyError:
# it's not a number, name, or path
print "Invalid world name or path"
parser.print_help()
print "Invalid world name or path"
sys.exit(1)
except KeyError:
# it was an invalid number
print "Invalid world number"
parser.print_help()
print "Invalid world number"
sys.exit(1)
if not options.cachedir:

View File

@@ -114,7 +114,7 @@ class QuadtreeGen(object):
yradius >= worldobj.maxrow and -yradius <= worldobj.minrow:
break
else:
raise ValueError("Your map is waaaay too big!")
raise ValueError("Your map is waaaay too big! Use the '-z' or '--zoom' options.")
self.p = p
else: