Merge branch 'master' of git://github.com/brownan/Minecraft-Overviewer
This commit is contained in:
34
chunk.py
34
chunk.py
@@ -50,7 +50,12 @@ def get_lvldata(filename, x, y):
|
|||||||
"""Takes a filename and chunkcoords and returns the Level struct, which contains all the
|
"""Takes a filename and chunkcoords and returns the Level struct, which contains all the
|
||||||
level info"""
|
level info"""
|
||||||
|
|
||||||
|
try:
|
||||||
d = nbt.load_from_region(filename, x, y)
|
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)
|
if not d: raise NoSuchChunk(x,y)
|
||||||
return d[1]['Level']
|
return d[1]['Level']
|
||||||
|
|
||||||
@@ -97,21 +102,6 @@ def get_tileentity_data(level):
|
|||||||
data = level['TileEntities']
|
data = level['TileEntities']
|
||||||
return data
|
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
|
# 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,
|
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])
|
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:
|
try:
|
||||||
self._level = get_lvldata(self.regionfile, self.chunkX, self.chunkY)
|
self._level = get_lvldata(self.regionfile, self.chunkX, self.chunkY)
|
||||||
except NoSuchChunk, e:
|
except NoSuchChunk, e:
|
||||||
#logging.debug("Skipping non-existant chunk")
|
logging.debug("Skipping non-existant chunk")
|
||||||
raise
|
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
|
return self._level
|
||||||
level = property(_load_level)
|
level = property(_load_level)
|
||||||
|
|
||||||
@@ -689,7 +676,14 @@ class ChunkRenderer(object):
|
|||||||
if not img:
|
if not img:
|
||||||
img = Image.new("RGBA", (384, 1728), (38,92,255,0))
|
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]
|
blockid = blocks[x,y,z]
|
||||||
|
|
||||||
# the following blocks don't have textures that can be pre-computed from the blockid
|
# the following blocks don't have textures that can be pre-computed from the blockid
|
||||||
|
|||||||
11
gmap.py
11
gmap.py
@@ -71,6 +71,13 @@ def main():
|
|||||||
if not os.path.exists(worlddir):
|
if not os.path.exists(worlddir):
|
||||||
# world given is either world number, or name
|
# world given is either world number, or name
|
||||||
worlds = world.get_worlds()
|
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:
|
try:
|
||||||
worldnum = int(worlddir)
|
worldnum = int(worlddir)
|
||||||
worlddir = worlds[worldnum]['path']
|
worlddir = worlds[worldnum]['path']
|
||||||
@@ -80,13 +87,13 @@ def main():
|
|||||||
worlddir = worlds[worlddir]['path']
|
worlddir = worlds[worlddir]['path']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# it's not a number, name, or path
|
# it's not a number, name, or path
|
||||||
print "Invalid world name or path"
|
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
print "Invalid world name or path"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# it was an invalid number
|
# it was an invalid number
|
||||||
print "Invalid world number"
|
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
print "Invalid world number"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not options.cachedir:
|
if not options.cachedir:
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class QuadtreeGen(object):
|
|||||||
yradius >= worldobj.maxrow and -yradius <= worldobj.minrow:
|
yradius >= worldobj.maxrow and -yradius <= worldobj.minrow:
|
||||||
break
|
break
|
||||||
else:
|
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
|
self.p = p
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user