From 92f5351cf94a241d9af12db82af75ef618aae707 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 25 Jan 2014 06:20:09 -0500 Subject: [PATCH] And make a loud message if there isn't a modcontainer found, substitute Minecraft. In general, this can only happen for coremods not properly registering their code. Closes #363 --- .../cpw/mods/fml/common/eventhandler/EventBus.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fml/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java b/fml/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java index 3dfe41122..7d6e3078d 100644 --- a/fml/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java +++ b/fml/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java @@ -6,11 +6,13 @@ import java.util.ArrayList; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import org.apache.logging.log4j.Level; import com.google.common.collect.MapMaker; import com.google.common.reflect.TypeToken; +import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; @@ -34,7 +36,13 @@ public class EventBus return; } - listenerOwners.put(target, Loader.instance().activeModContainer()); + ModContainer activeModContainer = Loader.instance().activeModContainer(); + if (activeModContainer == null) + { + FMLLog.log(Level.ERROR, new Throwable(), "Unable to determine registrant mod for %s. This is a critical error and should be impossible", target); + activeModContainer = Loader.instance().getMinecraftModContainer(); + } + listenerOwners.put(target, activeModContainer); Set> supers = TypeToken.of(target.getClass()).getTypes().rawTypes(); for (Method method : target.getClass().getMethods()) { @@ -61,7 +69,7 @@ public class EventBus throw new IllegalArgumentException("Method " + method + " has @SubscribeEvent annotation, but takes a argument that is not an Event " + eventType); } - register(eventType, target, method, Loader.instance().activeModContainer()); + register(eventType, target, method, activeModContainer); break; } }