Search in sources :

Example 6 with Lifecycle

use of org.spongepowered.common.launch.Lifecycle in project SpongeCommon by SpongePowered.

the class SpongeForge method onClientSetup.

private void onClientSetup(final FMLClientSetupEvent event) {
    final Client minecraft = (Client) event.getMinecraftSupplier().get();
    final Lifecycle lifecycle = Launch.instance().lifecycle();
    lifecycle.establishGlobalRegistries();
    lifecycle.establishDataProviders();
    lifecycle.callRegisterDataEvent();
    lifecycle.establishClientRegistries(minecraft);
    lifecycle.callStartingEngineEvent(minecraft);
}
Also used : Lifecycle(org.spongepowered.common.launch.Lifecycle) Client(org.spongepowered.api.Client)

Example 7 with Lifecycle

use of org.spongepowered.common.launch.Lifecycle in project SpongeCommon by SpongePowered.

the class SpongeForge method onCommonSetup.

private void onCommonSetup(final FMLCommonSetupEvent event) {
    final Lifecycle lifecycle = Launch.instance().lifecycle();
    lifecycle.callConstructEvent();
    lifecycle.callRegisterFactoryEvent();
    lifecycle.callRegisterBuilderEvent();
    lifecycle.callRegisterChannelEvent();
    lifecycle.establishGameServices();
    lifecycle.establishDataKeyListeners();
    SpongePacketHandler.init((SpongeChannelManager) Sponge.channelManager());
    // TODO Add attributes for HumanEntity to relevant event
    this.logger.info("SpongeForge v{} initialized", Launch.instance().platformPlugin().metadata().version());
}
Also used : Lifecycle(org.spongepowered.common.launch.Lifecycle)

Example 8 with Lifecycle

use of org.spongepowered.common.launch.Lifecycle in project SpongeCommon by SpongePowered.

the class MainMixin method impl$configurePackRepository.

@Redirect(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;getLevelPath(Lnet/minecraft/world/level/storage/LevelResource;)Ljava/nio/file/Path;"))
private static Path impl$configurePackRepository(final LevelStorageSource.LevelStorageAccess levelSave, final LevelResource folderName) {
    final Path datapackDir = levelSave.getLevelPath(folderName);
    final Lifecycle lifecycle = Launch.instance().lifecycle();
    lifecycle.establishGlobalRegistries();
    lifecycle.establishDataProviders();
    lifecycle.callRegisterDataEvent();
    lifecycle.callRegisterDataPackValueEvent(datapackDir);
    return datapackDir;
}
Also used : Path(java.nio.file.Path) Lifecycle(org.spongepowered.common.launch.Lifecycle) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 9 with Lifecycle

use of org.spongepowered.common.launch.Lifecycle in project SpongeCommon by SpongePowered.

the class MinecraftMixin method impl$callStartedEngineAndLoadedGame.

@Inject(method = "<init>", at = @At("RETURN"))
private void impl$callStartedEngineAndLoadedGame(CallbackInfo ci) {
    // Save config now that registries have been initialized
    ConfigHandle.setSaveSuppressed(false);
    final Lifecycle lifecycle = Launch.instance().lifecycle();
    lifecycle.callStartedEngineEvent(this);
    lifecycle.callLoadedGameEvent();
}
Also used : Lifecycle(org.spongepowered.common.launch.Lifecycle) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 10 with Lifecycle

use of org.spongepowered.common.launch.Lifecycle in project SpongeCommon by SpongePowered.

the class SpongeForge method onServerAboutToStart.

@SubscribeEvent
public void onServerAboutToStart(final FMLServerAboutToStartEvent event) {
    // Save config now that registries have been initialized
    ConfigHandle.setSaveSuppressed(false);
    final Lifecycle lifecycle = Launch.instance().lifecycle();
    lifecycle.establishServerServices();
    lifecycle.establishServerFeatures();
    lifecycle.establishServerRegistries((Server) event.getServer());
    lifecycle.callStartingEngineEvent((Server) event.getServer());
}
Also used : Lifecycle(org.spongepowered.common.launch.Lifecycle) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

Lifecycle (org.spongepowered.common.launch.Lifecycle)12 Inject (org.spongepowered.asm.mixin.injection.Inject)5 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)3 Path (java.nio.file.Path)1 Client (org.spongepowered.api.Client)1 Redirect (org.spongepowered.asm.mixin.injection.Redirect)1 MinecraftBridge (org.spongepowered.common.bridge.client.MinecraftBridge)1