package squeek.asmhelper;

import java.util.HashMap;
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;

public class ObfHelper
{
	// initialized in AppleCore.injectData
	public static boolean obfuscated = false;
	private static HashMap<String, String> classNameToObfClassNameCache = new HashMap<String, String>();
	private static HashMap<String, String> obfClassNameToClassNameCache = new HashMap<String, String>();

	private static void cacheObfClassMapping(String obfClassName, String className)
	{
		obfClassNameToClassNameCache.put(obfClassName, className);
		classNameToObfClassNameCache.put(className, obfClassName);
	}

	public static String toDeobfClassName(String obfClassName)
	{
		if (obfuscated)
		{
			if (!obfClassNameToClassNameCache.containsKey(obfClassName))
				cacheObfClassMapping(obfClassName, FMLDeobfuscatingRemapper.INSTANCE.map(obfClassName.replace('.', '/')).replace('/', '.'));

			return obfClassNameToClassNameCache.get(obfClassName);
		}
		else
			return obfClassName;
	}

	public static String toObfClassName(String deobfClassName)
	{
		if (obfuscated)
		{
			if (!classNameToObfClassNameCache.containsKey(deobfClassName))
				cacheObfClassMapping(FMLDeobfuscatingRemapper.INSTANCE.unmap(deobfClassName.replace('.', '/')).replace('/', '.'), deobfClassName);

			return classNameToObfClassNameCache.get(deobfClassName);
		}
		else
			return deobfClassName;
	}

	public static String getInternalClassName(String className)
	{
		return toObfClassName(className).replace('.', '/');
	}

	public static String getDescriptor(String className)
	{
		return "L" + getInternalClassName(className) + ";";
	}
}

@@ -36,20 +36,102 @@
 ava.
-util.HashMap
+io.IOException;%0Aimport java.util.HashMap;%0Aimport net.minecraft.launchwrapper.LaunchClassLoader
 ;%0Aim
@@ -235,62 +235,23 @@
 %0A%7B%0A%09
-// initialized in AppleCore.injectData%0A%09public
+private
  static 
 bool
@@ -246,17 +246,17 @@
  static 
-b
+B
 oolean o
@@ -271,13 +271,12 @@
 d = 
-false
+null
 ;%0A%09p
@@ -478,16 +478,624 @@
 ng%3E();%0A%0A
+%09/**%0A%09 * can be initialized by a core mod in injectData by %0A%09 * using the value of %22runtimeDeobfuscationEnabled%22 to%0A%09 * avoid the class loader lookup in isObfuscated%0A%09 */%0A%09public static void setObfuscated(boolean obfuscated)%0A%09%7B%0A%09%09ObfHelper.obfuscated = obfuscated;%0A%09%7D%0A%0A%09public static boolean isObfuscated()%0A%09%7B%0A%09%09if (obfuscated == null)%0A%09%09%7B%0A%09%09%09try%0A%09%09%09%7B%0A%09%09%09%09byte%5B%5D bytes = ((LaunchClassLoader) ObfHelper.class.getClassLoader()).getClassBytes(%22net.minecraft.world.World%22);%0A%09%09%09%09ObfHelper.setObfuscated(bytes == null);%0A%09%09%09%7D%0A%09%09%09catch (IOException e)%0A%09%09%09%7B%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return obfuscated;%0A%09%7D%0A%0A
 %09private
@@ -1357,33 +1357,35 @@
 sName)%0A%09%7B%0A%09%09if (
-o
+isO
 bfuscated)%0A%09%09%7B%0A%09
@@ -1369,32 +1369,34 @@
 if (isObfuscated
+()
 )%0A%09%09%7B%0A%09%09%09if (!ob
@@ -1737,33 +1737,35 @@
 sName)%0A%09%7B%0A%09%09if (
-o
+isO
 bfuscated)%0A%09%09%7B%0A%09
@@ -1757,16 +1757,18 @@
 fuscated
+()
 )%0A%09%09%7B%0A%09%09

Fix ObfHelper.obfuscated depending on a core mod to initialize it