removed old biome code
This commit is contained in:
@@ -627,96 +627,6 @@ class Textures(object):
|
|||||||
return None
|
return None
|
||||||
return (img, self.generate_opaque_mask(img))
|
return (img, self.generate_opaque_mask(img))
|
||||||
|
|
||||||
##
|
|
||||||
## Biomes
|
|
||||||
##
|
|
||||||
|
|
||||||
currentBiomeFile = None
|
|
||||||
currentBiomeData = None
|
|
||||||
grasscolor = None
|
|
||||||
foliagecolor = None
|
|
||||||
watercolor = None
|
|
||||||
_north = None
|
|
||||||
|
|
||||||
def prepareBiomeData(worlddir):
|
|
||||||
global grasscolor, foliagecolor, watercolor
|
|
||||||
|
|
||||||
# skip if the color files are already loaded
|
|
||||||
if grasscolor and foliagecolor:
|
|
||||||
return
|
|
||||||
|
|
||||||
biomeDir = os.path.join(worlddir, "biomes")
|
|
||||||
if not os.path.exists(biomeDir):
|
|
||||||
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
|
|
||||||
try:
|
|
||||||
grasscolor = list(_load_image("grasscolor.png").getdata())
|
|
||||||
foliagecolor = list(_load_image("foliagecolor.png").getdata())
|
|
||||||
# don't force the water color just yet
|
|
||||||
# since the biome extractor doesn't know about it
|
|
||||||
try:
|
|
||||||
watercolor = list(_load_image("watercolor.png").getdata())
|
|
||||||
except IOError:
|
|
||||||
pass
|
|
||||||
except IOError:
|
|
||||||
try:
|
|
||||||
grasscolor = list(Image.open(os.path.join(biomeDir,"grasscolor.png")).getdata())
|
|
||||||
foliagecolor = list(Image.open(os.path.join(biomeDir,"foliagecolor.png")).getdata())
|
|
||||||
except Exception:
|
|
||||||
# clear anything that managed to get set
|
|
||||||
grasscolor = None
|
|
||||||
foliagecolor = None
|
|
||||||
watercolor = 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
|
|
||||||
'''
|
|
||||||
|
|
||||||
global currentBiomeFile, currentBiomeData
|
|
||||||
global _north
|
|
||||||
biomeX = chunkX // 32
|
|
||||||
biomeY = chunkY // 32
|
|
||||||
rots = 0
|
|
||||||
if _north == 1:
|
|
||||||
temp = biomeX
|
|
||||||
biomeX = biomeY
|
|
||||||
biomeY = -temp-1
|
|
||||||
rots = 3
|
|
||||||
elif _north == 2:
|
|
||||||
biomeX = -biomeX-1
|
|
||||||
biomeY = -biomeY-1
|
|
||||||
rots = 2
|
|
||||||
elif _north == 3:
|
|
||||||
temp = biomeX
|
|
||||||
biomeX = -biomeY-1
|
|
||||||
biomeY = temp
|
|
||||||
rots = 1
|
|
||||||
|
|
||||||
biomeFile = "b.%d.%d.biome" % (biomeX, biomeY)
|
|
||||||
if biomeFile == currentBiomeFile:
|
|
||||||
return currentBiomeData
|
|
||||||
|
|
||||||
try:
|
|
||||||
with open(os.path.join(worlddir, "biomes", biomeFile), "rb") as f:
|
|
||||||
rawdata = f.read()
|
|
||||||
# make sure the file size is correct
|
|
||||||
if not len(rawdata) == 512 * 512 * 2:
|
|
||||||
raise Exception("Biome file %s is not valid." % (biomeFile,))
|
|
||||||
data = numpy.reshape(numpy.rot90(numpy.reshape(
|
|
||||||
numpy.frombuffer(rawdata, dtype=numpy.dtype(">u2")),
|
|
||||||
(512,512)),rots), -1)
|
|
||||||
except IOError:
|
|
||||||
data = None
|
|
||||||
pass # no biome data
|
|
||||||
|
|
||||||
currentBiomeFile = biomeFile
|
|
||||||
currentBiomeData = data
|
|
||||||
return data
|
|
||||||
|
|
||||||
##
|
##
|
||||||
## The other big one: @material and associated framework
|
## The other big one: @material and associated framework
|
||||||
##
|
##
|
||||||
|
|||||||
Reference in New Issue
Block a user