diff --git a/src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java b/src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java index 3967759ea..2621914bf 100644 --- a/src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java +++ b/src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java @@ -44,12 +44,13 @@ import static net.minecraftforge.fml.Logging.LOADING; public class AutomaticEventSubscriber { private static final Logger LOGGER = LogManager.getLogger(); + private static final Type AUTO_SUBSCRIBER = Type.getType(Mod.EventBusSubscriber.class); public static void inject(final ModContainer mod, final ModFileScanData scanData, final ClassLoader loader) { if (scanData == null) return; LOGGER.debug(LOADING,"Attempting to inject @EventBusSubscriber classes into the eventbus for {}", mod.getModId()); List ebsTargets = scanData.getAnnotations().stream(). - filter(annotationData -> Objects.equals(annotationData.getAnnotationType(), Type.getType(Mod.EventBusSubscriber.class))). + filter(annotationData -> AUTO_SUBSCRIBER.equals(annotationData.getAnnotationType())). collect(Collectors.toList()); ebsTargets.forEach(ad -> { diff --git a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java index 5b7b0c3ad..150f89f1f 100644 --- a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java +++ b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java @@ -120,9 +120,6 @@ public class FMLModContainer extends ModContainer private void preinitMod(LifecycleEventProvider.LifecycleEvent lifecycleEvent) { - LOGGER.debug(LOADING, "Injecting Automatic event subscribers for {}", getModId()); - AutomaticEventSubscriber.inject(this, this.scanResults, this.modClass.getClassLoader()); - LOGGER.debug(LOADING, "Completed Automatic event subscribers for {}", getModId()); } private void constructMod(LifecycleEventProvider.LifecycleEvent event) @@ -138,6 +135,9 @@ public class FMLModContainer extends ModContainer LOGGER.error(LOADING,"Failed to create mod instance. ModID: {}, class {}", getModId(), modClass.getName(), e); throw new ModLoadingException(modInfo, event.fromStage(), "fml.modloading.failedtoloadmod", e, modClass); } + LOGGER.debug(LOADING, "Injecting Automatic event subscribers for {}", getModId()); + AutomaticEventSubscriber.inject(this, this.scanResults, this.modClass.getClassLoader()); + LOGGER.debug(LOADING, "Completed Automatic event subscribers for {}", getModId()); } @Override