From 5925fa7c79429ad243728e45ec7ac14b8ca1c223 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 27 Aug 2013 12:31:37 -0400 Subject: [PATCH] Allow coremods to properly inject asset readers. --- fml/common/cpw/mods/fml/common/FMLDummyContainer.java | 11 ++++++++++- .../cpw/mods/fml/common/InjectedModContainer.java | 2 +- fml/common/cpw/mods/fml/common/Loader.java | 3 +-- .../cpw/mods/fml/common/asm/FMLSanityChecker.java | 2 ++ .../cpw/mods/fml/relauncher/CoreModManager.java | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/fml/common/cpw/mods/fml/common/FMLDummyContainer.java b/fml/common/cpw/mods/fml/common/FMLDummyContainer.java index 083a471d8..f86021784 100644 --- a/fml/common/cpw/mods/fml/common/FMLDummyContainer.java +++ b/fml/common/cpw/mods/fml/common/FMLDummyContainer.java @@ -12,6 +12,7 @@ package cpw.mods.fml.common; +import java.io.File; import java.security.cert.Certificate; import java.util.Arrays; import java.util.Map; @@ -26,6 +27,9 @@ import net.minecraft.world.storage.WorldInfo; import com.google.common.eventbus.EventBus; +import cpw.mods.fml.client.FMLFileResourcePack; +import cpw.mods.fml.client.FMLFolderResourcePack; +import cpw.mods.fml.common.asm.FMLSanityChecker; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.ItemData; @@ -124,9 +128,14 @@ public class FMLDummyContainer extends DummyModContainer implements WorldAccessC return certificates != null ? certificates[0] : null; } + @Override + public File getSource() + { + return FMLSanityChecker.fmlLocation; + } @Override public Class getCustomResourcePackClass() { - return super.getCustomResourcePackClass(); + return getSource().isDirectory() ? FMLFolderResourcePack.class : FMLFileResourcePack.class; } } diff --git a/fml/common/cpw/mods/fml/common/InjectedModContainer.java b/fml/common/cpw/mods/fml/common/InjectedModContainer.java index df5b7ff4d..0d92367ef 100644 --- a/fml/common/cpw/mods/fml/common/InjectedModContainer.java +++ b/fml/common/cpw/mods/fml/common/InjectedModContainer.java @@ -30,7 +30,7 @@ public class InjectedModContainer implements ModContainer public InjectedModContainer(ModContainer mc, File source) { - this.source = source; + this.source = source != null ? source : new File("minecraft.jar"); this.wrappedContainer = mc; } diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java index 9b5bc3567..9b6dd2fe2 100644 --- a/fml/common/cpw/mods/fml/common/Loader.java +++ b/fml/common/cpw/mods/fml/common/Loader.java @@ -322,7 +322,6 @@ public class Loader FMLLog.fine("Building injected Mod Containers %s", injectedContainers); // Add in the MCP mod container mods.add(new InjectedModContainer(mcp,new File("minecraft.jar"))); - File coremod = new File(minecraftDir,"coremods"); for (String cont : injectedContainers) { ModContainer mc; @@ -335,7 +334,7 @@ public class Loader FMLLog.log(Level.SEVERE, e, "A problem occured instantiating the injected mod container %s", cont); throw new LoaderException(e); } - mods.add(new InjectedModContainer(mc,coremod)); + mods.add(new InjectedModContainer(mc,mc.getSource())); } ModDiscoverer discoverer = new ModDiscoverer(); FMLLog.fine("Attempting to load mods contained in the minecraft jar file and associated classes"); diff --git a/fml/common/cpw/mods/fml/common/asm/FMLSanityChecker.java b/fml/common/cpw/mods/fml/common/asm/FMLSanityChecker.java index 1e2f6ea1d..c77aeb6bf 100644 --- a/fml/common/cpw/mods/fml/common/asm/FMLSanityChecker.java +++ b/fml/common/cpw/mods/fml/common/asm/FMLSanityChecker.java @@ -85,6 +85,7 @@ public class FMLSanityChecker implements IFMLCallHook } private LaunchClassLoader cl; + public static File fmlLocation; @Override public Void call() throws Exception @@ -239,6 +240,7 @@ public class FMLSanityChecker implements IFMLCallHook { cl = (LaunchClassLoader) data.get("classLoader"); File mcDir = (File)data.get("mcLocation"); + fmlLocation = (File)data.get("coremodLocation"); FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName")); ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side()); } diff --git a/fml/common/cpw/mods/fml/relauncher/CoreModManager.java b/fml/common/cpw/mods/fml/relauncher/CoreModManager.java index 61be9e06c..9fd38b96b 100644 --- a/fml/common/cpw/mods/fml/relauncher/CoreModManager.java +++ b/fml/common/cpw/mods/fml/relauncher/CoreModManager.java @@ -113,7 +113,7 @@ public class CoreModManager loadPlugins = new ArrayList(); for (String rootPluginName : rootPlugins) { - loadCoreMod(classLoader, rootPluginName, null); + loadCoreMod(classLoader, rootPluginName, new File(FMLTweaker.getJarLocation())); } if (loadPlugins.isEmpty())