From 6de655df47fe96d9bc09ca03f976d9e00211f520 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 3 Sep 2012 21:14:11 -0400 Subject: [PATCH] Fix CJB mod compatibilty for real. Gui container registration can now happen in the constructor. YUK! --- .../common/modloader/ModLoaderModContainer.java | 14 ++++++++++---- .../common/modloader/ModLoaderNetworkHandler.java | 12 ++++++++---- .../mods/fml/common/network/NetworkRegistry.java | 6 ++++++ fml/common/cpw/mods/fml/relauncher/Downloader.java | 5 ----- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java b/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java index 6a0efd830..5887b746f 100644 --- a/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java +++ b/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java @@ -493,13 +493,19 @@ public class ModLoaderModContainer implements ModContainer Class modClazz = (Class) modClassLoader.loadBaseModClass(modClazzName); configureMod(modClazz, event.getASMHarvestedData()); isNetworkMod = FMLNetworkHandler.instance().registerNetworkMod(this, modClazz, event.getASMHarvestedData()); - Constructor ctor = modClazz.getConstructor(); - ctor.setAccessible(true); - mod = modClazz.newInstance(); + ModLoaderNetworkHandler dummyHandler = null; if (!isNetworkMod) { FMLLog.fine("Injecting dummy network mod handler for BaseMod %s", getModId()); - FMLNetworkHandler.instance().registerNetworkMod(new ModLoaderNetworkHandler(this, mod)); + dummyHandler = new ModLoaderNetworkHandler(this); + FMLNetworkHandler.instance().registerNetworkMod(dummyHandler); + } + Constructor ctor = modClazz.getConstructor(); + ctor.setAccessible(true); + mod = modClazz.newInstance(); + if (dummyHandler != null) + { + dummyHandler.setBaseMod(mod); } ProxyInjector.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide()); } diff --git a/fml/common/cpw/mods/fml/common/modloader/ModLoaderNetworkHandler.java b/fml/common/cpw/mods/fml/common/modloader/ModLoaderNetworkHandler.java index b8119bab6..5efdfa3a0 100644 --- a/fml/common/cpw/mods/fml/common/modloader/ModLoaderNetworkHandler.java +++ b/fml/common/cpw/mods/fml/common/modloader/ModLoaderNetworkHandler.java @@ -9,10 +9,14 @@ public class ModLoaderNetworkHandler extends NetworkModHandler { private BaseModProxy baseMod; - public ModLoaderNetworkHandler(ModLoaderModContainer mlmc, BaseModProxy mod) + public ModLoaderNetworkHandler(ModLoaderModContainer mlmc) { super(mlmc, null); - this.baseMod = mod; + } + + public void setBaseMod(BaseModProxy baseMod) + { + this.baseMod = baseMod; } @Override @@ -20,13 +24,13 @@ public class ModLoaderNetworkHandler extends NetworkModHandler { return false; } - + @Override public boolean requiresServerSide() { return false; } - + @Override public boolean acceptVersion(String version) { diff --git a/fml/common/cpw/mods/fml/common/network/NetworkRegistry.java b/fml/common/cpw/mods/fml/common/network/NetworkRegistry.java index bedc5460f..fb67f8c69 100644 --- a/fml/common/cpw/mods/fml/common/network/NetworkRegistry.java +++ b/fml/common/cpw/mods/fml/common/network/NetworkRegistry.java @@ -31,6 +31,7 @@ import com.google.common.collect.Sets; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.network.FMLPacket.Type; @@ -263,6 +264,11 @@ public class NetworkRegistry public void registerGuiHandler(Object mod, IGuiHandler handler) { ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod); + if (mc == null) + { + mc = Loader.instance().activeModContainer(); + FMLLog.log(Level.WARNING, "Mod %s attempted to register a gui network handler during a construction phase", mc.getModId()); + } NetworkModHandler nmh = FMLNetworkHandler.instance().findNetworkModHandler(mc); if (nmh == null) { diff --git a/fml/common/cpw/mods/fml/relauncher/Downloader.java b/fml/common/cpw/mods/fml/relauncher/Downloader.java index cf8a3c251..34269ba88 100644 --- a/fml/common/cpw/mods/fml/relauncher/Downloader.java +++ b/fml/common/cpw/mods/fml/relauncher/Downloader.java @@ -24,11 +24,6 @@ public class Downloader extends JOptionPane boolean stopIt; Thread pokeThread; - public Downloader() - { - super(); - } - private Box makeProgressPanel() { Box box = Box.createVerticalBox();