Move @EventBusSubscriber application to just after construction instead of pre-init.
This commit is contained in:
parent
849bc00b46
commit
3765d912a5
2 changed files with 5 additions and 4 deletions
|
@ -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<ModFileScanData.AnnotationData> 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 -> {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue