Search in sources :

Example 1 with SpongeLifecycle

use of org.spongepowered.common.SpongeLifecycle in project SpongeCommon by SpongePowered.

the class BootstrapMixin_Forge method forge$startLifecycle.

// @formatter:on
@Inject(method = "bootStrap", at = @At("HEAD"))
private static void forge$startLifecycle(final CallbackInfo ci) {
    if (BootstrapMixin_Forge.isBootstrapped) {
        return;
    }
    final ForgeLaunch launch = Launch.instance();
    final Stage stage = SpongeGuice.getInjectorStage(launch.injectionStage());
    SpongeCommon.logger().debug("Creating injector in stage '{}'", stage);
    final Injector bootstrapInjector = launch.createInjector();
    final SpongeLifecycle lifecycle = bootstrapInjector.getInstance(SpongeLifecycle.class);
    launch.setLifecycle(lifecycle);
    lifecycle.establishFactories();
    lifecycle.establishBuilders();
    lifecycle.initTimings();
}
Also used : Injector(com.google.inject.Injector) Stage(com.google.inject.Stage) SpongeLifecycle(org.spongepowered.common.SpongeLifecycle) ForgeLaunch(org.spongepowered.forge.launch.ForgeLaunch) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with SpongeLifecycle

use of org.spongepowered.common.SpongeLifecycle in project SpongeCommon by SpongePowered.

the class VanillaBootstrap method perform.

public static void perform(final String engineName, final Runnable engineStart) {
    final Stage stage = SpongeGuice.getInjectorStage(Launch.instance().injectionStage());
    SpongeCommon.logger().debug("Creating injector in stage '{}'", stage);
    final Injector bootstrapInjector = Launch.instance().createInjector();
    final SpongeLifecycle lifecycle = bootstrapInjector.getInstance(SpongeLifecycle.class);
    Launch.instance().setLifecycle(lifecycle);
    lifecycle.establishFactories();
    lifecycle.establishBuilders();
    lifecycle.initTimings();
    ((VanillaPluginManager) Launch.instance().pluginManager()).loadPlugins((VanillaPluginPlatform) Launch.instance().pluginPlatform());
    lifecycle.callConstructEvent();
    lifecycle.callRegisterFactoryEvent();
    lifecycle.callRegisterBuilderEvent();
    lifecycle.callRegisterChannelEvent();
    lifecycle.establishGameServices();
    lifecycle.establishDataKeyListeners();
    SpongePacketHandler.init((SpongeChannelManager) Sponge.channelManager());
    Launch.instance().logger().info("Loading Minecraft {}, please wait...", engineName);
    engineStart.run();
}
Also used : Injector(com.google.inject.Injector) Stage(com.google.inject.Stage) VanillaPluginManager(org.spongepowered.vanilla.launch.plugin.VanillaPluginManager) SpongeLifecycle(org.spongepowered.common.SpongeLifecycle)

Aggregations

Injector (com.google.inject.Injector)2 Stage (com.google.inject.Stage)2 SpongeLifecycle (org.spongepowered.common.SpongeLifecycle)2 Inject (org.spongepowered.asm.mixin.injection.Inject)1 ForgeLaunch (org.spongepowered.forge.launch.ForgeLaunch)1 VanillaPluginManager (org.spongepowered.vanilla.launch.plugin.VanillaPluginManager)1