Add callback on TextureStitched to control texture loading.

This commit is contained in:
LexManos 2013-03-04 19:36:19 -08:00
parent 2e947b364c
commit ebdc10eb1d
3 changed files with 88 additions and 17 deletions

View File

@ -1,12 +1,13 @@
--- ../src_base/minecraft/net/minecraft/client/renderer/texture/TextureManager.java
+++ ../src_work/minecraft/net/minecraft/client/renderer/texture/TextureManager.java
@@ -66,15 +66,20 @@
@@ -66,17 +66,27 @@
public List func_94266_e(String par1Str)
{
+ return createNewTexture(par1Str, par1Str);
+ return createNewTexture(par1Str, par1Str, null);
+ }
+ public List createNewTexture(String textureName, String textureFile)
+
+ public List createNewTexture(String textureName, String textureFile, TextureStitched stitched)
+ {
+ String par1Str = textureFile;
ArrayList arraylist = new ArrayList();
@ -21,5 +22,12 @@
- String s1 = this.func_98146_d(par1Str);
+ String s1 = textureName;
if (this.func_98147_a(par1Str, itexturepack))
- if (this.func_98147_a(par1Str, itexturepack))
+ if (stitched != null && stitched.loadTexture(this, itexturepack, textureName, textureFile, bufferedimage, arraylist))
+ {
+ ;
+ }
+ else if (this.func_98147_a(par1Str, itexturepack))
{
int k = j;
int l = j;

View File

@ -1,27 +1,45 @@
--- ../src_base/minecraft/net/minecraft/client/renderer/texture/TextureMap.java
+++ ../src_work/minecraft/net/minecraft/client/renderer/texture/TextureMap.java
@@ -95,8 +95,18 @@
while (iterator.hasNext())
{
String s = (String)iterator.next();
@@ -90,13 +90,22 @@
StitchHolder stitchholder = new StitchHolder(texture);
stitcher.func_94312_a(stitchholder);
hashmap.put(stitchholder, Arrays.asList(new Texture[] {texture}));
- Iterator iterator = this.field_94256_j.keySet().iterator();
-
- while (iterator.hasNext())
- {
- String s = (String)iterator.next();
- String s1 = this.field_94254_c + s + this.field_94251_d;
- List list = TextureManager.func_94267_b().func_94266_e(s1);
+ String s1;
+ if (s.indexOf(':') == -1)
+
+ for (Map.Entry<String, TextureStitched> entry : ((Map<String, TextureStitched>)field_94256_j).entrySet())
+ {
+ String name = entry.getKey();
+ String path;
+ if (name.indexOf(':') == -1)
+ {
+ s1 = this.field_94254_c + s + this.field_94251_d;
+ path = this.field_94254_c + name + this.field_94251_d;
+ }
+ else
+ {
+ String domain = s.substring(0,s.indexOf(':'));
+ String file = s.substring(s.indexOf(':')+1);
+ s1 = "mods/" + domain +"/" + field_94254_c + file + field_94251_d;
+ String domain = name.substring(0,name.indexOf(':'));
+ String file = name.substring(name.indexOf(':')+1);
+ path = "mods/" + domain +"/" + field_94254_c + file + field_94251_d;
+ }
+ List list = TextureManager.func_94267_b().createNewTexture(s, s1);
+ List list = TextureManager.func_94267_b().createNewTexture(name, path, entry.getValue());
if (!list.isEmpty())
{
@@ -150,7 +160,17 @@
@@ -116,7 +125,7 @@
}
this.field_94257_h = stitcher.func_94306_e();
- iterator = stitcher.func_94309_g().iterator();
+ Iterator iterator = stitcher.func_94309_g().iterator();
while (iterator.hasNext())
{
@@ -150,7 +159,17 @@
if (list1.size() > 1)
{
this.field_94258_i.add(texturestitched);
@ -40,7 +58,7 @@
ITexturePack itexturepack = Minecraft.getMinecraft().texturePackList.getSelectedTexturePack();
boolean flag1 = !itexturepack.func_98138_b("/" + this.field_94254_c + s2 + ".png", false);
@@ -218,4 +238,37 @@
@@ -218,4 +237,37 @@
{
return this.field_94250_g;
}

View File

@ -0,0 +1,45 @@
--- ../src_base/minecraft/net/minecraft/client/renderer/texture/TextureStitched.java
+++ ../src_work/minecraft/net/minecraft/client/renderer/texture/TextureStitched.java
@@ -2,9 +2,13 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+
+import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.List;
+
+import net.minecraft.client.texturepacks.ITexturePack;
import net.minecraft.util.Icon;
import net.minecraft.util.Tuple;
@@ -196,4 +200,28 @@
this.field_94236_i = arraylist;
}
}
+
+ //===================================================================================================
+ // Forge Start
+ //===================================================================================================
+ /**
+ * Called when texture packs are refreshed, from TextureManager.createNewTexture,
+ * allows for finer control over loading the animation lists and verification of the image.
+ * If the return value from this is true, no further loading will be done by vanilla code.
+ *
+ * You need to add all Texture's to the textures argument. At the end of this function at least one
+ * entry should be in that argument, or a error should of been thrown.
+ *
+ * @param manager The invoking manager
+ * @param texturepack Current texture pack
+ * @param name The name of the texture
+ * @param fileName Resource path for this texture
+ * @param image Buffered image of the loaded resource
+ * @param textures ArrayList of element type Texture, split textures should be added to this list for the stitcher to handle.
+ * @return Return true to skip further vanilla texture loading for this texture
+ */
+ public boolean loadTexture(TextureManager manager, ITexturePack texturepack, String name, String fileName, BufferedImage image, ArrayList textures)
+ {
+ return false;
+ }
}