From 429dfc3d3d71fa59e0411cb711d32c751f373a40 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 2 Mar 2013 10:30:45 -0500 Subject: [PATCH] Build, and use, MC versioned deobfuscation data --- fml/build.xml | 3 +++ .../mods/fml/common/asm/FMLSanityChecker.java | 2 +- .../deobf/FMLDeobfuscatingRemapper.java | 5 +++-- .../mods/fml/relauncher/CoreFMLLibraries.java | 4 ++-- .../mods/fml/relauncher/FMLInjectionData.java | 9 ++++++-- .../relauncher/RelaunchLibraryManager.java | 22 +++++++++++++++++-- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/fml/build.xml b/fml/build.xml index ac42f2c66..e08af069d 100644 --- a/fml/build.xml +++ b/fml/build.xml @@ -16,6 +16,7 @@ + @@ -210,6 +211,8 @@ + + diff --git a/fml/common/cpw/mods/fml/common/asm/FMLSanityChecker.java b/fml/common/cpw/mods/fml/common/asm/FMLSanityChecker.java index e4a59b17b..a2bdd67ed 100644 --- a/fml/common/cpw/mods/fml/common/asm/FMLSanityChecker.java +++ b/fml/common/cpw/mods/fml/common/asm/FMLSanityChecker.java @@ -126,7 +126,7 @@ public class FMLSanityChecker implements IFMLCallHook public void injectData(Map data) { cl = (RelaunchClassLoader) data.get("classLoader"); - FMLDeobfuscatingRemapper.INSTANCE.setup((File)data.get("mcLocation"), cl); + FMLDeobfuscatingRemapper.INSTANCE.setup((File)data.get("mcLocation"), cl, (String) data.get("deobfuscationFileName")); } } diff --git a/fml/common/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java b/fml/common/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java index 68bb2bf2d..710787679 100644 --- a/fml/common/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java +++ b/fml/common/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java @@ -51,15 +51,16 @@ public class FMLDeobfuscatingRemapper extends Remapper { private FMLDeobfuscatingRemapper() { + classNameBiMap=ImmutableBiMap.of(); } - public void setup(File mcDir, RelaunchClassLoader classLoader) + public void setup(File mcDir, RelaunchClassLoader classLoader, String deobfFileName) { this.classLoader = classLoader; try { File libDir = new File(mcDir, "lib"); - File mapData = new File(libDir, "deobfuscation_data.zip"); + File mapData = new File(libDir, deobfFileName); ZipFile mapZip = new ZipFile(mapData); ZipEntry classData = mapZip.getEntry("joined.srg"); ZipInputSupplier zis = new ZipInputSupplier(mapZip, classData); diff --git a/fml/common/cpw/mods/fml/relauncher/CoreFMLLibraries.java b/fml/common/cpw/mods/fml/relauncher/CoreFMLLibraries.java index 400ae5b46..f74bc9cde 100644 --- a/fml/common/cpw/mods/fml/relauncher/CoreFMLLibraries.java +++ b/fml/common/cpw/mods/fml/relauncher/CoreFMLLibraries.java @@ -2,8 +2,8 @@ package cpw.mods.fml.relauncher; public class CoreFMLLibraries implements ILibrarySet { - private static String[] libraries = { "argo-small-3.2.jar","guava-14.0-rc3.jar","asm-all-4.1.jar", "bcprov-jdk15on-148.jar" }; - private static String[] checksums = { "58912ea2858d168c50781f956fa5b59f0f7c6b51", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", "054986e962b88d8660ae4566475658469595ef58", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65" }; + private static String[] libraries = { "argo-small-3.2.jar","guava-14.0-rc3.jar","asm-all-4.1.jar", "bcprov-jdk15on-148.jar", FMLInjectionData.debfuscationDataName() }; + private static String[] checksums = { "58912ea2858d168c50781f956fa5b59f0f7c6b51", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", "054986e962b88d8660ae4566475658469595ef58", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", FMLInjectionData.deobfuscationDataHash }; @Override public String[] getLibraries() diff --git a/fml/common/cpw/mods/fml/relauncher/FMLInjectionData.java b/fml/common/cpw/mods/fml/relauncher/FMLInjectionData.java index c4b86c604..3ef47d5b8 100644 --- a/fml/common/cpw/mods/fml/relauncher/FMLInjectionData.java +++ b/fml/common/cpw/mods/fml/relauncher/FMLInjectionData.java @@ -17,6 +17,8 @@ public class FMLInjectionData static String build; static String mccversion; static String mcpversion; + static String deobfuscationDataHash; + public static List containers = new ArrayList(); static void build(File mcHome, RelaunchClassLoader classLoader) @@ -43,10 +45,13 @@ public class FMLInjectionData build = properties.getProperty("fmlbuild.build.number", "missing"); mccversion = properties.getProperty("fmlbuild.mcversion", "missing"); mcpversion = properties.getProperty("fmlbuild.mcpversion", "missing"); - - + deobfuscationDataHash = properties.getProperty("fmlbuild.deobfuscation.hash","deadbeef"); } + static String debfuscationDataName() + { + return "deobfuscation_data_"+mccversion+".zip"; + } public static Object[] data() { return new Object[] { major, minor, rev, build, mccversion, mcpversion, minecraftHome, containers }; diff --git a/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java b/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java index 1532af995..e95e79e21 100644 --- a/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java +++ b/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java @@ -35,8 +35,23 @@ public class RelaunchLibraryManager private static Map pluginLocations; private static List loadPlugins; private static List libraries; + private static boolean deobfuscatedEnvironment; + public static void handleLaunch(File mcDir, RelaunchClassLoader actualClassLoader) { + try + { + // Are we in a 'decompiled' environment? + actualClassLoader.getClassBytes("net.minecraft.world.World"); + FMLRelaunchLog.info("Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation"); + deobfuscatedEnvironment = true; + } + catch (IOException e1) + { + FMLRelaunchLog.fine("Enabling runtime deobfuscation"); + deobfuscatedEnvironment = false; + } + pluginLocations = new HashMap(); loadPlugins = new ArrayList(); libraries = new ArrayList(); @@ -240,8 +255,10 @@ public class RelaunchLibraryManager } } // Deobfuscation transformer, always last - actualClassLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer"); - + if (!deobfuscatedEnvironment) + { + actualClassLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer"); + } downloadMonitor.updateProgressString("Running coremod plugins"); Map data = new HashMap(); data.put("mcLocation", mcDir); @@ -259,6 +276,7 @@ public class RelaunchLibraryManager IFMLCallHook call = (IFMLCallHook) Class.forName(setupClass, true, actualClassLoader).newInstance(); Map callData = new HashMap(); callData.put("classLoader", actualClassLoader); + callData.put("deobfuscationFileName", FMLInjectionData.debfuscationDataName()); call.injectData(callData); call.call(); }