From 802cd30dc8abe925b8728ce2ebe0b6e23681c028 Mon Sep 17 00:00:00 2001 From: Alex Cline Date: Thu, 30 Dec 2010 15:31:03 -0500 Subject: [PATCH 1/9] Added conditional to only add signs that are not blank to the POI list. --- chunk.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/chunk.py b/chunk.py index b3e702c..95d7a51 100644 --- a/chunk.py +++ b/chunk.py @@ -905,18 +905,18 @@ class ChunkRenderer(object): for entity in tileEntities: if entity['id'] == 'Sign': - - # convert the blockID coordinates from local chunk - # coordinates to global world coordinates - newPOI = dict(type="sign", - x= entity['x'], - y= entity['y'], - z= entity['z'], - msg="%s \n%s \n%s \n%s" % - (entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']), - chunk= (self.chunkX, self.chunkY), - ) - self.queue.put(["newpoi", newPOI]) + if entity['Text1'] != '' and entity['Text2'] != '' and entity['Text3'] != '' and entity['Text3'] != '': + # convert the blockID coordinates from local chunk + # coordinates to global world coordinates + newPOI = dict(type="sign", + x= entity['x'], + y= entity['y'], + z= entity['z'], + msg="%s \n%s \n%s \n%s" % + (entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']), + chunk= (self.chunkX, self.chunkY), + ) + self.queue.put(["newpoi", newPOI]) # check to see if there are any signs in the persistentData list that are from this chunk. From 0136cc1eba7079e27543011a26b5b8dce9158b4c Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Fri, 31 Dec 2010 17:59:14 -0500 Subject: [PATCH 2/9] changed textures.py to use global declarations instead of sys.modules[__name__] --- textures.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/textures.py b/textures.py index 499ce6f..a019037 100644 --- a/textures.py +++ b/textures.py @@ -749,42 +749,46 @@ def prepareLeafTexture(color): currentBiomeFile = None currentBiomeData = None +grasscolor = None +foliagecolor = None def prepareBiomeData(worlddir): biomeDir = os.path.join(worlddir, "EXTRACTEDBIOMES") if not os.path.exists(biomeDir): raise Exception("EXTRACTEDBIOMES not found") - t = sys.modules[__name__] + global grasscolor, foliagecolor # try to find the biome color images. If _find_file can't locate them # then try looking in the EXTRACTEDBIOMES folder try: - t.grasscolor = list(Image.open(_find_file("grasscolor.png")).getdata()) - t.foliagecolor = list(Image.open(_find_file("foliagecolor.png")).getdata()) + grasscolor = list(Image.open(_find_file("grasscolor.png")).getdata()) + foliagecolor = list(Image.open(_find_file("foliagecolor.png")).getdata()) except IOError: try: - t.grasscolor = list(Image.open(os.path.join(biomeDir,"grasscolor.png")).getdata()) - t.foliagecolor = list(Image.open(os.path.join(biomeDir,"foliagecolor.png")).getdata()) + grasscolor = list(Image.open(os.path.join(biomeDir,"grasscolor.png")).getdata()) + foliagecolor = list(Image.open(os.path.join(biomeDir,"foliagecolor.png")).getdata()) except: - t.grasscolor = None - t.foliagecolor = None + # clear anything that managed to get set + grasscolor = None + foliagecolor = None def getBiomeData(worlddir, chunkX, chunkY): '''Opens the worlddir and reads in the biome color information from the .biome files. See also: http://www.minecraftforum.net/viewtopic.php?f=25&t=80902 ''' - t = sys.modules[__name__] + + global currentBiomeFile, currentBiomeData biomeFile = "%d.%d.biome" % ( int(math.floor(chunkX/8)*8), int(math.floor(chunkY/8)*8) ) - if biomeFile == t.currentBiomeFile: + if biomeFile == currentBiomeFile: return currentBiomeData - t.currentBiomeFile = biomeFile + currentBiomeFile = biomeFile f = open(os.path.join(worlddir, "EXTRACTEDBIOMES", biomeFile), "rb") rawdata = f.read() @@ -792,7 +796,7 @@ def getBiomeData(worlddir, chunkX, chunkY): data = numpy.frombuffer(rawdata, dtype=numpy.dtype(">u2")) - t.currentBiomeData = data + currentBiomeData = data return data # This set holds block ids that require special pre-computing. These are typically From ee1e7c3aa9ba4ae485090cb31d6dc4920ed6c15b Mon Sep 17 00:00:00 2001 From: Alex Cline Date: Fri, 31 Dec 2010 20:45:02 -0500 Subject: [PATCH 3/9] Changed blank sign logic to use aheadley's suggestion. --- chunk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chunk.py b/chunk.py index 95d7a51..754772a 100644 --- a/chunk.py +++ b/chunk.py @@ -905,7 +905,8 @@ class ChunkRenderer(object): for entity in tileEntities: if entity['id'] == 'Sign': - if entity['Text1'] != '' and entity['Text2'] != '' and entity['Text3'] != '' and entity['Text3'] != '': + msg=' \n'.join([entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']]) + if not msg.strip(): # convert the blockID coordinates from local chunk # coordinates to global world coordinates newPOI = dict(type="sign", From 97aa81311c721a047a0bf96916bce78fd9b182b7 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Fri, 31 Dec 2010 23:35:18 -0500 Subject: [PATCH 4/9] Fixed empty sign handling, updated findSigns.py --- chunk.py | 5 ++--- contrib/findSigns.py | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/chunk.py b/chunk.py index 754772a..ecfda39 100644 --- a/chunk.py +++ b/chunk.py @@ -906,15 +906,14 @@ class ChunkRenderer(object): for entity in tileEntities: if entity['id'] == 'Sign': msg=' \n'.join([entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']]) - if not msg.strip(): + if msg.strip(): # convert the blockID coordinates from local chunk # coordinates to global world coordinates newPOI = dict(type="sign", x= entity['x'], y= entity['y'], z= entity['z'], - msg="%s \n%s \n%s \n%s" % - (entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']), + msg=msg, chunk= (self.chunkX, self.chunkY), ) self.queue.put(["newpoi", newPOI]) diff --git a/contrib/findSigns.py b/contrib/findSigns.py index 104cb42..a5bfa5d 100644 --- a/contrib/findSigns.py +++ b/contrib/findSigns.py @@ -45,16 +45,18 @@ for dirpath, dirnames, filenames in os.walk(worlddir): data = nbt.load(full)[1]['Level']['TileEntities'] for entity in data: if entity['id'] == 'Sign': - newPOI = dict(type="sign", - x= entity['x'], - y= entity['y'], - z= entity['z'], - msg="%s \n%s \n%s \n%s" % - (entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']), - chunk= (entity['x']/16, entity['z']/16), - ) - POI.append(newPOI) - print "Found sign at (%d, %d, %d): %r" % (newPOI['x'], newPOI['y'], newPOI['z'], newPOI['msg']) + msg=' \n'.join([entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']]) + #print "checking -->%s<--" % msg.strip() + if msg.strip(): + newPOI = dict(type="sign", + x= entity['x'], + y= entity['y'], + z= entity['z'], + msg=msg, + chunk= (entity['x']/16, entity['z']/16), + ) + POI.append(newPOI) + print "Found sign at (%d, %d, %d): %r" % (newPOI['x'], newPOI['y'], newPOI['z'], newPOI['msg']) From b2d8c415caea0f2dc70ba119901d281b274cf0ff Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Sat, 1 Jan 2011 15:43:45 -0800 Subject: [PATCH 5/9] added check to textures.py prepareBiomeData so it will only run once per process --- textures.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/textures.py b/textures.py index a019037..4c93b98 100644 --- a/textures.py +++ b/textures.py @@ -753,12 +753,16 @@ grasscolor = None foliagecolor = None def prepareBiomeData(worlddir): + global grasscolor, foliagecolor + + # skip if the color files are already loaded + if grasscolor and foliagecolor: + return + biomeDir = os.path.join(worlddir, "EXTRACTEDBIOMES") if not os.path.exists(biomeDir): raise Exception("EXTRACTEDBIOMES not found") - global grasscolor, foliagecolor - # try to find the biome color images. If _find_file can't locate them # then try looking in the EXTRACTEDBIOMES folder try: From 0ab56ce1d9db4f7686ffd450c7c7287705679919 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Sat, 1 Jan 2011 15:45:36 -0800 Subject: [PATCH 6/9] made sure biome color arrays are loaded in each thread --- chunk.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chunk.py b/chunk.py index b3e702c..573fbb5 100644 --- a/chunk.py +++ b/chunk.py @@ -211,6 +211,8 @@ class ChunkRenderer(object): if self.world.useBiomeData: + # make sure we've at least *tried* to load the color arrays in this process... + textures.prepareBiomeData(self.world.worlddir) if not textures.grasscolor or not textures.foliagecolor: raise Exception("Can't find grasscolor.png or foliagecolor.png") From c43e7c0dbf6f5037f73e5fdf5cf5d3711cb36714 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Sat, 1 Jan 2011 19:00:44 -0500 Subject: [PATCH 7/9] alpha_over warning will now only print once per run --- composite.py | 2 +- gmap.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/composite.py b/composite.py index 45719a9..abe5562 100644 --- a/composite.py +++ b/composite.py @@ -28,7 +28,7 @@ try: from _composite import alpha_over as _extension_alpha_over extension_alpha_over = _extension_alpha_over except ImportError: - logging.warning("alpha_over extension not found; using default PIL paste()") + pass def alpha_over(dest, src, pos_or_rect=(0, 0), mask=None): """Composite src over dest, using mask as the alpha channel (if diff --git a/gmap.py b/gmap.py index 8a41c40..51d97bc 100755 --- a/gmap.py +++ b/gmap.py @@ -28,6 +28,7 @@ import multiprocessing import time import logging import optimizeimages +import composite logging.basicConfig(level=logging.INFO,format="%(asctime)s [%(levelname)s] %(message)s") @@ -118,6 +119,8 @@ def main(): logging.info("Welcome to Minecraft Overviewer!") logging.debug("Current log level: {0}".format(logging.getLogger().level)) + if not composite.extension_alpha_over: + logging.info("Notice: alpha_over extension not found; using default PIL paste()") useBiomeData = os.path.exists(os.path.join(worlddir, 'EXTRACTEDBIOMES')) if not useBiomeData: From 23b7e90c54329a714f9823b66b0b365ad2050b5d Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Wed, 5 Jan 2011 02:38:57 +0100 Subject: [PATCH 8/9] Fix findTrueSpawn for spawn in y = 128 --- world.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/world.py b/world.py index 7ae08b0..4de2a7a 100644 --- a/world.py +++ b/world.py @@ -220,9 +220,11 @@ class WorldRenderer(object): inChunkZ = spawnZ - (chunkY*16) ## find the first air block - while (blockArray[inChunkX, inChunkZ, spawnY] != 0): + while (blockArray[inChunkX, inChunkZ, spawnY] != 0 and spawnY != 127): spawnY += 1 - + + if spawnY == 127 and blockArray[inChunkX, inChunkZ, spawnY] != 0 : + spawnY = 128 # get the right spawnY coordinate for markers.js self.POI.append( dict(x=spawnX, y=spawnY, z=spawnZ, msg="Spawn", type="spawn", chunk=(inChunkX,inChunkZ))) From ad9756fa8cdfe193c452461e0f2bd0f458ba4bfc Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Wed, 5 Jan 2011 15:09:55 +0100 Subject: [PATCH 9/9] Change to a better looking and better maintainable code. (thanks blixt) --- world.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/world.py b/world.py index 4de2a7a..1a9f38e 100644 --- a/world.py +++ b/world.py @@ -220,11 +220,10 @@ class WorldRenderer(object): inChunkZ = spawnZ - (chunkY*16) ## find the first air block - while (blockArray[inChunkX, inChunkZ, spawnY] != 0 and spawnY != 127): + while (blockArray[inChunkX, inChunkZ, spawnY] != 0): spawnY += 1 - - if spawnY == 127 and blockArray[inChunkX, inChunkZ, spawnY] != 0 : - spawnY = 128 # get the right spawnY coordinate for markers.js + if spawnY == 128: + break self.POI.append( dict(x=spawnX, y=spawnY, z=spawnZ, msg="Spawn", type="spawn", chunk=(inChunkX,inChunkZ)))