0

Fixed the way texture.py searched for foliage, grass and chests textures.

This is a "quick-and-dirty fix", you may improve it as I'm novice in Python.
Default files in data/textures have been renamed to reflect changes in new 1.6 texture packs (aka resource packs)
This commit is contained in:
joe-mojo
2013-08-23 00:24:21 +02:00
parent 6b76e9c2fa
commit 603e60bd0d
5 changed files with 19 additions and 6 deletions

View File

@@ -149,14 +149,17 @@ class Textures(object):
# a list of subdirectories to search for a given file,
# after the obvious '.'
search_dirs = ['anim', 'misc', 'environment', 'item']
search_dirs = ['anim', 'misc', 'environment', 'item', 'entity', 'entity/chest']
search_zip_paths = [filename,] + [d + '/' + filename for d in search_dirs]
def search_dir(base):
"""Search the given base dir for filename, in search_dirs."""
for path in [os.path.join(base, d, filename) for d in ['',] + search_dirs]:
if verbose: logging.info('filename: ' + filename + ' ; path: ' + path)
if os.path.isfile(path):
return path
return None
if verbose: logging.info('search_zip_paths: ' + ', '.join(search_zip_paths))
# we've sucessfully loaded something from here before, so let's quickly try
# this before searching again
@@ -191,6 +194,15 @@ class Textures(object):
return pack.open(packfilename)
except (KeyError, IOError):
pass
try:
# 2nd try with completed path.
packfilename = 'assets/minecraft/textures/' + packfilename
pack.getinfo(packfilename)
if verbose: logging.info("Found %s in '%s'", packfilename, self.find_file_local_path)
return pack.open(packfilename)
except (KeyError, IOError):
pass
except (zipfile.BadZipfile, IOError):
pass
@@ -408,15 +420,16 @@ class Textures(object):
def load_grass_color(self):
"""Helper function to load the grass color texture."""
if not hasattr(self, "grasscolor"):
self.grasscolor = list(self.load_image("grasscolor.png").getdata())
self.grasscolor = list(self.load_image("grass.png").getdata())
return self.grasscolor
def load_foliage_color(self):
"""Helper function to load the foliage color texture."""
if not hasattr(self, "foliagecolor"):
self.foliagecolor = list(self.load_image("foliagecolor.png").getdata())
self.foliagecolor = list(self.load_image("foliage.png").getdata())
return self.foliagecolor
#I guess "watercolor" is wrong. But I can't correct as my texture pack don't define water color.
def load_water_color(self):
"""Helper function to load the water color texture."""
if not hasattr(self, "watercolor"):
@@ -1791,8 +1804,8 @@ def chests(self, blockid, data):
# ancilData = 2,3,4,5 are used for this blockids
if data & 24 == 0:
if blockid == 130: t = self.load_image("enderchest.png")
else: t = self.load_image("chest.png")
if blockid == 130: t = self.load_image("ender.png")
else: t = self.load_image("normal.png")
# the textures is no longer in terrain.png, get it from
# item/chest.png and get by cropping all the needed stuff
@@ -1847,7 +1860,7 @@ def chests(self, blockid, data):
# large chest
# the textures is no longer in terrain.png, get it from
# item/chest.png and get all the needed stuff
t = self.load_image("largechest.png")
t = self.load_image("normal_double.png")
if t.size != (128,64): t = t.resize((128,64), Image.ANTIALIAS)
# top
top = t.crop((14,0,44,14))