0

Better handling of the biome tinting images.

If they're not found with _find_file, then look in the EXTRACTEDBIOME
folder in the worlddir.
This commit is contained in:
Andrew Chin
2010-12-05 01:35:12 -05:00
parent 251a89b7dc
commit e96bb91b82
3 changed files with 27 additions and 13 deletions

View File

@@ -503,7 +503,7 @@ class ChunkRenderer(object):
tileEntities = get_tileentity_data(self.level)
if self.world.useBiomeData:
biomeColorData = textures.prepareBiomeData(self.world.worlddir,
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))

View File

@@ -556,27 +556,37 @@ def prepareLeafTexture(color):
img.paste(top, (0,0), top)
return (img.convert("RGB"), img.split()[3])
#useBiomeData = os.path.exists(os.path.join(self.world, EXTRACTEDBIOMES))
#if not useBiomeData:
# logging.info("Notice: Not using biome data for tinting")
try:
grasscolor = list(Image.open(_find_file("grasscolor.png")).getdata())
foliagecolor = list(Image.open(_find_file("foliagecolor.png")).getdata())
except:
grasscolor = None
foliagecolor = None
currentBiomeFile = None
currentBiomeData = None
def prepareBiomeData(worlddir, chunkX, chunkY):
def prepareBiomeData(worlddir):
biomeDir = os.path.join(worlddir, "EXTRACTEDBIOMES")
if not os.path.exists(biomeDir):
raise Exception("EXTRACTEDBIOMES not found")
t = sys.modules[__name__]
# 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())
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())
except:
t.grasscolor = None
t.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__]
if not os.path.exists(os.path.join(worlddir, "EXTRACTEDBIOMES")):
raise Exception("EXTRACTEDBIOMES not found")
biomeFile = "%d.%d.biome" % (
int(math.floor(chunkX/8)*8),

View File

@@ -26,6 +26,7 @@ import numpy
import chunk
import nbt
import textures
"""
This module has routines related to generating all the chunks for a world
@@ -102,6 +103,9 @@ class WorldRenderer(object):
self.cachedir = cachedir
self.useBiomeData = useBiomeData
if self.useBiomeData:
textures.prepareBiomeData(worlddir)
self.chunklist = chunklist
# stores Points Of Interest to be mapped with markers