0

Merge remote-tracking branch 'joe-mojo/master', PR #974, Issue #973

This commit is contained in:
Aaron Griffith
2013-12-01 16:29:07 -05:00
5 changed files with 25 additions and 8 deletions

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -149,14 +149,17 @@ class Textures(object):
# a list of subdirectories to search for a given file, # a list of subdirectories to search for a given file,
# after the obvious '.' # after the obvious '.'
search_dirs = ['anim', 'misc', 'environment', 'item'] search_dirs = ['anim', 'misc', 'environment', 'item', 'item/chests', 'entity', 'entity/chest']
search_zip_paths = [filename,] + [d + '/' + filename for d in search_dirs] search_zip_paths = [filename,] + [d + '/' + filename for d in search_dirs]
def search_dir(base): def search_dir(base):
"""Search the given base dir for filename, in search_dirs.""" """Search the given base dir for filename, in search_dirs."""
for path in [os.path.join(base, d, filename) for d 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): if os.path.isfile(path):
return path return path
return None 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 # we've sucessfully loaded something from here before, so let's quickly try
# this before searching again # this before searching again
@@ -191,6 +194,15 @@ class Textures(object):
return pack.open(packfilename) return pack.open(packfilename)
except (KeyError, IOError): except (KeyError, IOError):
pass 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): except (zipfile.BadZipfile, IOError):
pass pass
@@ -408,15 +420,16 @@ class Textures(object):
def load_grass_color(self): def load_grass_color(self):
"""Helper function to load the grass color texture.""" """Helper function to load the grass color texture."""
if not hasattr(self, "grasscolor"): 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 return self.grasscolor
def load_foliage_color(self): def load_foliage_color(self):
"""Helper function to load the foliage color texture.""" """Helper function to load the foliage color texture."""
if not hasattr(self, "foliagecolor"): 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 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): def load_water_color(self):
"""Helper function to load the water color texture.""" """Helper function to load the water color texture."""
if not hasattr(self, "watercolor"): if not hasattr(self, "watercolor"):
@@ -1826,8 +1839,12 @@ def chests(self, blockid, data):
# ancilData = 2,3,4,5 are used for this blockids # ancilData = 2,3,4,5 are used for this blockids
if data & 24 == 0: if data & 24 == 0:
if blockid == 130: t = self.load_image("enderchest.png") if blockid == 130: t = self.load_image("ender.png")
else: t = self.load_image("chest.png") else:
try:
t = self.load_image("normal.png")
except (TextureException, IOError):
t = self.load_image("chest.png")
# the textures is no longer in terrain.png, get it from # the textures is no longer in terrain.png, get it from
# item/chest.png and get by cropping all the needed stuff # item/chest.png and get by cropping all the needed stuff
@@ -1882,7 +1899,7 @@ def chests(self, blockid, data):
# large chest # large chest
# the textures is no longer in terrain.png, get it from # the textures is no longer in terrain.png, get it from
# item/chest.png and get all the needed stuff # 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) if t.size != (128,64): t = t.resize((128,64), Image.ANTIALIAS)
# top # top
top = t.crop((14,0,44,14)) top = t.crop((14,0,44,14))
@@ -3197,7 +3214,7 @@ def comparator(self, blockid, data):
# trapdoor # trapdoor
# TODO the trapdoor is looks like a sprite when opened, that's not good # the trapdoor is looks like a sprite when opened, that's not good
@material(blockid=96, data=range(16), transparent=True, nospawn=True) @material(blockid=96, data=range(16), transparent=True, nospawn=True)
def trapdoor(self, blockid, data): def trapdoor(self, blockid, data):