From a6805c2e0c593dfdb9f698f7b8a370085506303d Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Thu, 3 Mar 2011 12:27:47 -0500 Subject: [PATCH] updated biome rendering to use latest Biome Extractor format --- README.rst | 8 ++++---- chunk.py | 13 ++++++++----- gmap.py | 2 +- textures.py | 12 ++++++------ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/README.rst b/README.rst index dd77116..f3f23b9 100644 --- a/README.rst +++ b/README.rst @@ -92,10 +92,10 @@ biome-accurate tinting, the Overviewer can use biome data produced by the Minecraft Biome Extractor tool. This tool can be downloaded from: http://www.minecraftforum.net/viewtopic.php?f=25&t=80902 -If the EXTRACTEDBIOMES folder is present in the world directory, then the -Overviewer will use the biome data to tint grass and leaves automatically -- -there is no command line option to turn this feature on. If this folder does -not exist, then the Overviewer will use a static tinting for grass and leaves. +If the "biomes" folder is present in the world directory, then the Overviewer +will use the biome data to tint grass and leaves automatically -- there is no +command line option to turn this feature on. If this folder does not exist, +then the Overviewer will use a static tinting for grass and leaves. Compiling the C Extension (optional) ------------------------------------ diff --git a/chunk.py b/chunk.py index 8e6245e..440f3f8 100644 --- a/chunk.py +++ b/chunk.py @@ -675,9 +675,9 @@ class ChunkRenderer(object): if self.world.useBiomeData: biomeColorData = textures.getBiomeData(self.world.worlddir, self.chunkX, self.chunkY) - # in the 8x8 block of biome data, what chunk is this?l - startX = (self.chunkX - int(math.floor(self.chunkX/8)*8)) - startY = (self.chunkY - int(math.floor(self.chunkY/8)*8)) + # in the 32x32 block of biome data, what chunk is this?l + startX = (self.chunkX - int(math.floor(self.chunkX/32)*32)) + startY = (self.chunkY - int(math.floor(self.chunkY/32)*32)) # Each block is 24x24 # The next block on the X axis adds 12px to x and subtracts 6px from y in the image @@ -717,14 +717,17 @@ class ChunkRenderer(object): continue if self.world.useBiomeData: + # 16 : number of blocks in a chunk (in one direction) + # 32 : number of chunks in a region (and biome file) in one direction + # so 16 * 32 == 512 : number of blocks in biome file, in one direction if blockid == 2: #grass - index = biomeColorData[ ((startY*16)+y) * 128 + (startX*16) + x] + index = biomeColorData[ ((startY*16)+y) * 512 + (startX*16) + x] c = textures.grasscolor[index] # only tint the top texture t = textures.prepareGrassTexture(c) elif blockid == 18: # leaves - index = biomeColorData[ ((startY*16)+y) * 128 + (startX*16) + x] + index = biomeColorData[ ((startY*16)+y) * 512 + (startX*16) + x] c = textures.foliagecolor[index] t = textures.prepareLeafTexture(c) diff --git a/gmap.py b/gmap.py index acfacb1..11f29ee 100755 --- a/gmap.py +++ b/gmap.py @@ -134,7 +134,7 @@ def main(): 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')) + useBiomeData = os.path.exists(os.path.join(worlddir, 'biomes')) if not useBiomeData: logging.info("Notice: Not using biome data for tinting") diff --git a/textures.py b/textures.py index 11f65de..ae06f87 100644 --- a/textures.py +++ b/textures.py @@ -824,9 +824,9 @@ def prepareBiomeData(worlddir): if grasscolor and foliagecolor: return - biomeDir = os.path.join(worlddir, "EXTRACTEDBIOMES") + biomeDir = os.path.join(worlddir, "biomes") if not os.path.exists(biomeDir): - raise Exception("EXTRACTEDBIOMES not found") + raise Exception("biomes not found") # try to find the biome color images. If _find_file can't locate them # then try looking in the EXTRACTEDBIOMES folder @@ -850,16 +850,16 @@ def getBiomeData(worlddir, chunkX, chunkY): global currentBiomeFile, currentBiomeData - biomeFile = "%d.%d.biome" % ( - int(math.floor(chunkX/8)*8), - int(math.floor(chunkY/8)*8) + biomeFile = "b.%d.%d.biome" % ( + int(math.floor(chunkX/32)), + int(math.floor(chunkY/32)) ) if biomeFile == currentBiomeFile: return currentBiomeData currentBiomeFile = biomeFile - f = open(os.path.join(worlddir, "EXTRACTEDBIOMES", biomeFile), "rb") + f = open(os.path.join(worlddir, "biomes", biomeFile), "rb") rawdata = f.read() f.close()