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:
2
chunk.py
2
chunk.py
@@ -503,7 +503,7 @@ class ChunkRenderer(object):
|
|||||||
tileEntities = get_tileentity_data(self.level)
|
tileEntities = get_tileentity_data(self.level)
|
||||||
|
|
||||||
if self.world.useBiomeData:
|
if self.world.useBiomeData:
|
||||||
biomeColorData = textures.prepareBiomeData(self.world.worlddir,
|
biomeColorData = textures.getBiomeData(self.world.worlddir,
|
||||||
self.chunkX, self.chunkY)
|
self.chunkX, self.chunkY)
|
||||||
# in the 8x8 block of biome data, what chunk is this?l
|
# in the 8x8 block of biome data, what chunk is this?l
|
||||||
startX = (self.chunkX - int(math.floor(self.chunkX/8)*8))
|
startX = (self.chunkX - int(math.floor(self.chunkX/8)*8))
|
||||||
|
|||||||
34
textures.py
34
textures.py
@@ -556,27 +556,37 @@ def prepareLeafTexture(color):
|
|||||||
img.paste(top, (0,0), top)
|
img.paste(top, (0,0), top)
|
||||||
return (img.convert("RGB"), img.split()[3])
|
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
|
currentBiomeFile = None
|
||||||
currentBiomeData = 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
|
'''Opens the worlddir and reads in the biome color information
|
||||||
from the .biome files. See also:
|
from the .biome files. See also:
|
||||||
http://www.minecraftforum.net/viewtopic.php?f=25&t=80902
|
http://www.minecraftforum.net/viewtopic.php?f=25&t=80902
|
||||||
'''
|
'''
|
||||||
t = sys.modules[__name__]
|
t = sys.modules[__name__]
|
||||||
if not os.path.exists(os.path.join(worlddir, "EXTRACTEDBIOMES")):
|
|
||||||
raise Exception("EXTRACTEDBIOMES not found")
|
|
||||||
|
|
||||||
biomeFile = "%d.%d.biome" % (
|
biomeFile = "%d.%d.biome" % (
|
||||||
int(math.floor(chunkX/8)*8),
|
int(math.floor(chunkX/8)*8),
|
||||||
|
|||||||
4
world.py
4
world.py
@@ -26,6 +26,7 @@ import numpy
|
|||||||
|
|
||||||
import chunk
|
import chunk
|
||||||
import nbt
|
import nbt
|
||||||
|
import textures
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This module has routines related to generating all the chunks for a world
|
This module has routines related to generating all the chunks for a world
|
||||||
@@ -102,6 +103,9 @@ class WorldRenderer(object):
|
|||||||
self.cachedir = cachedir
|
self.cachedir = cachedir
|
||||||
self.useBiomeData = useBiomeData
|
self.useBiomeData = useBiomeData
|
||||||
|
|
||||||
|
if self.useBiomeData:
|
||||||
|
textures.prepareBiomeData(worlddir)
|
||||||
|
|
||||||
self.chunklist = chunklist
|
self.chunklist = chunklist
|
||||||
|
|
||||||
# stores Points Of Interest to be mapped with markers
|
# stores Points Of Interest to be mapped with markers
|
||||||
|
|||||||
Reference in New Issue
Block a user