changed textures.py to use global declarations instead of sys.modules[__name__]
This commit is contained in:
26
textures.py
26
textures.py
@@ -749,42 +749,46 @@ def prepareLeafTexture(color):
|
|||||||
|
|
||||||
currentBiomeFile = None
|
currentBiomeFile = None
|
||||||
currentBiomeData = None
|
currentBiomeData = None
|
||||||
|
grasscolor = None
|
||||||
|
foliagecolor = None
|
||||||
|
|
||||||
def prepareBiomeData(worlddir):
|
def prepareBiomeData(worlddir):
|
||||||
biomeDir = os.path.join(worlddir, "EXTRACTEDBIOMES")
|
biomeDir = os.path.join(worlddir, "EXTRACTEDBIOMES")
|
||||||
if not os.path.exists(biomeDir):
|
if not os.path.exists(biomeDir):
|
||||||
raise Exception("EXTRACTEDBIOMES not found")
|
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
|
# try to find the biome color images. If _find_file can't locate them
|
||||||
# then try looking in the EXTRACTEDBIOMES folder
|
# then try looking in the EXTRACTEDBIOMES folder
|
||||||
try:
|
try:
|
||||||
t.grasscolor = list(Image.open(_find_file("grasscolor.png")).getdata())
|
grasscolor = list(Image.open(_find_file("grasscolor.png")).getdata())
|
||||||
t.foliagecolor = list(Image.open(_find_file("foliagecolor.png")).getdata())
|
foliagecolor = list(Image.open(_find_file("foliagecolor.png")).getdata())
|
||||||
except IOError:
|
except IOError:
|
||||||
try:
|
try:
|
||||||
t.grasscolor = list(Image.open(os.path.join(biomeDir,"grasscolor.png")).getdata())
|
grasscolor = list(Image.open(os.path.join(biomeDir,"grasscolor.png")).getdata())
|
||||||
t.foliagecolor = list(Image.open(os.path.join(biomeDir,"foliagecolor.png")).getdata())
|
foliagecolor = list(Image.open(os.path.join(biomeDir,"foliagecolor.png")).getdata())
|
||||||
except:
|
except:
|
||||||
t.grasscolor = None
|
# clear anything that managed to get set
|
||||||
t.foliagecolor = None
|
grasscolor = None
|
||||||
|
foliagecolor = None
|
||||||
|
|
||||||
def getBiomeData(worlddir, chunkX, chunkY):
|
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__]
|
|
||||||
|
global currentBiomeFile, currentBiomeData
|
||||||
|
|
||||||
biomeFile = "%d.%d.biome" % (
|
biomeFile = "%d.%d.biome" % (
|
||||||
int(math.floor(chunkX/8)*8),
|
int(math.floor(chunkX/8)*8),
|
||||||
int(math.floor(chunkY/8)*8)
|
int(math.floor(chunkY/8)*8)
|
||||||
)
|
)
|
||||||
if biomeFile == t.currentBiomeFile:
|
if biomeFile == currentBiomeFile:
|
||||||
return currentBiomeData
|
return currentBiomeData
|
||||||
|
|
||||||
t.currentBiomeFile = biomeFile
|
currentBiomeFile = biomeFile
|
||||||
|
|
||||||
f = open(os.path.join(worlddir, "EXTRACTEDBIOMES", biomeFile), "rb")
|
f = open(os.path.join(worlddir, "EXTRACTEDBIOMES", biomeFile), "rb")
|
||||||
rawdata = f.read()
|
rawdata = f.read()
|
||||||
@@ -792,7 +796,7 @@ def getBiomeData(worlddir, chunkX, chunkY):
|
|||||||
|
|
||||||
data = numpy.frombuffer(rawdata, dtype=numpy.dtype(">u2"))
|
data = numpy.frombuffer(rawdata, dtype=numpy.dtype(">u2"))
|
||||||
|
|
||||||
t.currentBiomeData = data
|
currentBiomeData = data
|
||||||
return data
|
return data
|
||||||
|
|
||||||
# This set holds block ids that require special pre-computing. These are typically
|
# This set holds block ids that require special pre-computing. These are typically
|
||||||
|
|||||||
Reference in New Issue
Block a user