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)
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
@@ -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', '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"):
|
||||||
@@ -1791,8 +1804,8 @@ 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: t = self.load_image("normal.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
|
||||||
@@ -1847,7 +1860,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))
|
||||||
|
|||||||