mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 20:52:34 +00:00
111 lines
4.1 KiB
Diff
111 lines
4.1 KiB
Diff
--- ../src_base/minecraft/net/minecraft/client/renderer/texture/TextureMap.java
|
|
+++ ../src_work/minecraft/net/minecraft/client/renderer/texture/TextureMap.java
|
|
@@ -21,6 +21,7 @@
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.util.Icon;
|
|
import net.minecraft.util.ReportedException;
|
|
+import net.minecraftforge.client.ForgeHooksClient;
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public class TextureMap extends AbstractTexture implements TickableTextureObject, IconRegister
|
|
@@ -62,6 +63,7 @@
|
|
Stitcher stitcher = new Stitcher(i, i, true);
|
|
this.mapTexturesStiched.clear();
|
|
this.listTextureStiched.clear();
|
|
+ ForgeHooksClient.onTextureStitchedPre(this);
|
|
Iterator iterator = this.field_110574_e.entrySet().iterator();
|
|
|
|
while (iterator.hasNext())
|
|
@@ -69,11 +71,14 @@
|
|
Entry entry = (Entry)iterator.next();
|
|
String s = (String)entry.getKey();
|
|
TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)entry.getValue();
|
|
- ResourceLocation resourcelocation = new ResourceLocation(this.basePath + s + ".png");
|
|
+ ResourceLocation resourcelocation = new ResourceLocation(fixDomain(basePath, s) + ".png");
|
|
|
|
try
|
|
{
|
|
- textureatlassprite.func_130100_a(par1ResourceManager.func_110536_a(resourcelocation));
|
|
+ if (!textureatlassprite.load(par1ResourceManager, resourcelocation))
|
|
+ {
|
|
+ continue;
|
|
+ }
|
|
}
|
|
catch (RuntimeException runtimeexception)
|
|
{
|
|
@@ -142,6 +147,7 @@
|
|
textureatlassprite1 = (TextureAtlasSprite)iterator1.next();
|
|
textureatlassprite1.copyFrom(this.missingImage);
|
|
}
|
|
+ ForgeHooksClient.onTextureStitchedPost(this);
|
|
}
|
|
|
|
private void func_110573_f()
|
|
@@ -212,6 +218,7 @@
|
|
if (par1Str == null)
|
|
{
|
|
(new RuntimeException("Don\'t register null!")).printStackTrace();
|
|
+ par1Str = "null"; //Don't allow things to actually register null..
|
|
}
|
|
|
|
Object object = (TextureAtlasSprite)this.field_110574_e.get(par1Str);
|
|
@@ -253,4 +260,58 @@
|
|
{
|
|
this.updateAnimations();
|
|
}
|
|
+
|
|
+ //===================================================================================================
|
|
+ // Forge Start
|
|
+ //===================================================================================================
|
|
+ /**
|
|
+ * Grabs the registered entry for the specified name, returning null if there was not a entry.
|
|
+ * Opposed to registerIcon, this will not instantiate the entry, useful to test if a mapping exists.
|
|
+ *
|
|
+ * @param name The name of the entry to find
|
|
+ * @return The registered entry, null if nothing was registered.
|
|
+ */
|
|
+ public TextureAtlasSprite getTextureExtry(String name)
|
|
+ {
|
|
+ return (TextureAtlasSprite)field_110574_e.get(name);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Adds a texture registry entry to this map for the specified name if one does not already exist.
|
|
+ * Returns false if the map already contains a entry for the specified name.
|
|
+ *
|
|
+ * @param name Entry name
|
|
+ * @param entry Entry instance
|
|
+ * @return True if the entry was added to the map, false otherwise.
|
|
+ */
|
|
+ public boolean setTextureEntry(String name, TextureAtlasSprite entry)
|
|
+ {
|
|
+ if (!field_110574_e.containsKey(name))
|
|
+ {
|
|
+ field_110574_e.put(name, entry);
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ //This properly moves the domain, if provided, to the front of the string before concatenating
|
|
+ private String fixDomain(String base, String complex)
|
|
+ {
|
|
+ int idx = complex.indexOf(':');
|
|
+ if (idx == -1)
|
|
+ {
|
|
+ return base + complex;
|
|
+ }
|
|
+
|
|
+ String name = complex.substring(idx + 1, complex.length());
|
|
+ if (idx > 1)
|
|
+ {
|
|
+ String domain = complex.substring(0, idx);
|
|
+ return domain + ':' + base + name;
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ return base + name;
|
|
+ }
|
|
+ }
|
|
}
|