From 7f5ec0eaef40a307699e71aa20faea4d1b443c6c Mon Sep 17 00:00:00 2001 From: LexManos Date: Wed, 3 Jul 2013 19:31:54 -0700 Subject: [PATCH] Fix domain issue with SoundPool entries. --- .../client/ForgeHooksClient.java | 21 ++++++++++++++++ .../client/audio/SoundPool.java.patch | 20 +++++++++++++++ .../renderer/texture/TextureMap.java.patch | 25 ++----------------- 3 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 patches/minecraft/net/minecraft/client/audio/SoundPool.java.patch diff --git a/client/net/minecraftforge/client/ForgeHooksClient.java b/client/net/minecraftforge/client/ForgeHooksClient.java index 91319b4076..34c83d7651 100644 --- a/client/net/minecraftforge/client/ForgeHooksClient.java +++ b/client/net/minecraftforge/client/ForgeHooksClient.java @@ -283,4 +283,25 @@ public class ForgeHooksClient stencilBits = 0; } } + + //This properly moves the domain, if provided, to the front of the string before concatenating + public static 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; + } + } } diff --git a/patches/minecraft/net/minecraft/client/audio/SoundPool.java.patch b/patches/minecraft/net/minecraft/client/audio/SoundPool.java.patch new file mode 100644 index 0000000000..456e957e2b --- /dev/null +++ b/patches/minecraft/net/minecraft/client/audio/SoundPool.java.patch @@ -0,0 +1,20 @@ +--- ../src_base/minecraft/net/minecraft/client/audio/SoundPool.java ++++ ../src_work/minecraft/net/minecraft/client/audio/SoundPool.java +@@ -11,6 +11,7 @@ + import java.util.Map; + import java.util.Random; + import net.minecraft.client.resources.ResourceManager; ++import net.minecraftforge.client.ForgeHooksClient; + + @SideOnly(Side.CLIENT) + public class SoundPool +@@ -71,7 +72,8 @@ + + private URL func_110654_c(String par1Str) throws MalformedURLException + { +- return new URL((URL)null, "minecraft:" + this.field_110656_d + "/" + par1Str, new SoundPoolProtocolHandler(this)); ++ String path = ForgeHooksClient.fixDomain(field_110656_d + "/", par1Str); ++ return new URL((URL)null, "minecraft:" + path, new SoundPoolProtocolHandler(this)); + } + + /** diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch index 1ac1446559..8ccfa7629b 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch @@ -21,7 +21,7 @@ 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"); ++ ResourceLocation resourcelocation = new ResourceLocation(ForgeHooksClient.fixDomain(basePath, s) + ".png"); try { @@ -49,7 +49,7 @@ } Object object = (TextureAtlasSprite)this.field_110574_e.get(par1Str); -@@ -253,4 +260,58 @@ +@@ -253,4 +260,37 @@ { this.updateAnimations(); } @@ -85,26 +85,5 @@ + 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; -+ } + } }