Search in sources :

Example 1 with ModLoadingException

use of net.minecraftforge.fml.ModLoadingException in project SpongeCommon by SpongePowered.

the class PluginModContainer method constructPlugin.

private void constructPlugin() {
    final FMLModContainerAccessor accessor = (FMLModContainerAccessor) (Object) this;
    try {
        PluginModContainer.LOGGER.trace(Logging.LOADING, "Loading plugin instance {} of type {}", getModId(), accessor.accessor$modClass().getName());
        final Injector childInjector = Launch.instance().lifecycle().platformInjector().createChildInjector(new PluginModule((PluginContainer) (Object) this, accessor.accessor$modClass()));
        final Object instance = childInjector.getInstance(accessor.accessor$modClass());
        accessor.accessor$setModInstance(instance);
        ((ForgeEventManager) MinecraftForge.EVENT_BUS).registerListeners((PluginContainer) (Object) this, instance);
        PluginModContainer.LOGGER.trace(Logging.LOADING, "Loaded plugin instance {} of type {}", getModId(), accessor.accessor$modClass().getName());
    } catch (final Throwable e) {
        PluginModContainer.LOGGER.error(Logging.LOADING, "Failed to create plugin instance. PluginID: {}, class {}", getModId(), accessor.accessor$modClass().getName(), e);
        throw new ModLoadingException(this.modInfo, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmod", e, accessor.accessor$modClass());
    }
    try {
        PluginModContainer.LOGGER.trace(Logging.LOADING, "Injecting Automatic event subscribers for {}", getModId());
        AutomaticEventSubscriber.inject(this, accessor.accessor$scanResults(), accessor.accessor$modClass().getClassLoader());
        PluginModContainer.LOGGER.trace(Logging.LOADING, "Completed Automatic event subscribers for {}", getModId());
    } catch (final Throwable e) {
        LOGGER.error(LOADING, "Failed to register automatic subscribers. PluginID: {}, class {}", getModId(), accessor.accessor$modClass().getName(), e);
        throw new ModLoadingException(this.modInfo, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmod", e, accessor.accessor$modClass());
    }
}
Also used : FMLModContainerAccessor(org.spongepowered.forge.accessor.fml.javafmlmod.FMLModContainerAccessor) ModLoadingException(net.minecraftforge.fml.ModLoadingException) PluginContainer(org.spongepowered.plugin.PluginContainer) Injector(com.google.inject.Injector) ForgeEventManager(org.spongepowered.forge.launch.event.ForgeEventManager) PluginModule(org.spongepowered.common.inject.plugin.PluginModule)

Example 2 with ModLoadingException

use of net.minecraftforge.fml.ModLoadingException in project MinecraftForge by MinecraftForge.

the class FMLModContainer method constructMod.

private void constructMod() {
    try {
        LOGGER.trace(LOADING, "Loading mod instance {} of type {}", getModId(), modClass.getName());
        this.modInstance = modClass.getDeclaredConstructor().newInstance();
        LOGGER.trace(LOADING, "Loaded mod instance {} of type {}", getModId(), modClass.getName());
    } catch (Throwable e) {
        LOGGER.error(LOADING, "Failed to create mod instance. ModID: {}, class {}", getModId(), modClass.getName(), e);
        throw new ModLoadingException(modInfo, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmod", e, modClass);
    }
    try {
        LOGGER.trace(LOADING, "Injecting Automatic event subscribers for {}", getModId());
        AutomaticEventSubscriber.inject(this, this.scanResults, this.modClass.getClassLoader());
        LOGGER.trace(LOADING, "Completed Automatic event subscribers for {}", getModId());
    } catch (Throwable e) {
        LOGGER.error(LOADING, "Failed to register automatic subscribers. ModID: {}, class {}", getModId(), modClass.getName(), e);
        throw new ModLoadingException(modInfo, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmod", e, modClass);
    }
}
Also used : ModLoadingException(net.minecraftforge.fml.ModLoadingException)

Example 3 with ModLoadingException

use of net.minecraftforge.fml.ModLoadingException in project MinecraftForge by MinecraftForge.

the class FMLModContainer method acceptEvent.

@Override
protected <T extends Event & IModBusEvent> void acceptEvent(final T e) {
    try {
        LOGGER.trace(LOADING, "Firing event for modid {} : {}", this.getModId(), e);
        this.eventBus.post(e);
        LOGGER.trace(LOADING, "Fired event for modid {} : {}", this.getModId(), e);
    } catch (Throwable t) {
        LOGGER.error(LOADING, "Caught exception during event {} dispatch for modid {}", e, this.getModId(), t);
        throw new ModLoadingException(modInfo, modLoadingStage, "fml.modloading.errorduringevent", t);
    }
}
Also used : ModLoadingException(net.minecraftforge.fml.ModLoadingException)

Aggregations

ModLoadingException (net.minecraftforge.fml.ModLoadingException)3 Injector (com.google.inject.Injector)1 PluginModule (org.spongepowered.common.inject.plugin.PluginModule)1 FMLModContainerAccessor (org.spongepowered.forge.accessor.fml.javafmlmod.FMLModContainerAccessor)1 ForgeEventManager (org.spongepowered.forge.launch.event.ForgeEventManager)1 PluginContainer (org.spongepowered.plugin.PluginContainer)1