-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3f80b7
commit b510e4e
Showing
12 changed files
with
103 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/main/java/net/neoforged/neoforge/internal/ModLoadingHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.internal; | ||
|
||
import java.util.concurrent.Executor; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.fml.ModList; | ||
import net.neoforged.fml.ModLoader; | ||
import net.neoforged.fml.ModWorkManager; | ||
import net.neoforged.fml.config.ConfigTracker; | ||
import net.neoforged.fml.config.ModConfig; | ||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; | ||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent; | ||
import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent; | ||
import net.neoforged.fml.event.lifecycle.InterModEnqueueEvent; | ||
import net.neoforged.fml.event.lifecycle.InterModProcessEvent; | ||
import net.neoforged.fml.loading.FMLEnvironment; | ||
import net.neoforged.fml.loading.FMLPaths; | ||
import net.neoforged.neoforge.network.registration.NetworkRegistry; | ||
import net.neoforged.neoforge.registries.GameData; | ||
import net.neoforged.neoforge.registries.RegistryManager; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
/** | ||
* Internal class for handling the steps of mod loading that are common for client, data and server runs. | ||
*/ | ||
// TODO: some form of error handling | ||
@ApiStatus.Internal | ||
public final class ModLoadingHandler { | ||
private ModLoadingHandler() {} | ||
|
||
private static boolean registriesLoaded = false; | ||
|
||
public static boolean areRegistriesLoaded() { | ||
return registriesLoaded; | ||
} | ||
|
||
public static void begin(Runnable periodicTask) { | ||
var syncExecutor = ModWorkManager.syncExecutor(); | ||
|
||
ModLoader.get().gatherAndInitializeMods(syncExecutor, ModWorkManager.parallelExecutor(), periodicTask); | ||
|
||
ModLoader.get().runInitTask("Registry initialization", syncExecutor, periodicTask, () -> { | ||
RegistryManager.postNewRegistryEvent(); | ||
GameData.unfreezeData(); | ||
GameData.postRegisterEvents(); | ||
GameData.freezeData(); | ||
registriesLoaded = true; | ||
}); | ||
} | ||
|
||
public static void load(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable periodicTask) { | ||
if (!ModLoader.isLoadingStateValid()) { | ||
return; | ||
} | ||
|
||
ModLoader.get().runInitTask("Config loading", syncExecutor, periodicTask, () -> { | ||
if (FMLEnvironment.dist == Dist.CLIENT) { | ||
ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.CLIENT, FMLPaths.CONFIGDIR.get()); | ||
} | ||
ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.COMMON, FMLPaths.CONFIGDIR.get()); | ||
}); | ||
|
||
ModLoader.get().dispatchParallelEvent("Common setup", syncExecutor, parallelExecutor, periodicTask, FMLCommonSetupEvent::new); | ||
ModLoader.get().dispatchParallelEvent("Sided setup", syncExecutor, parallelExecutor, periodicTask, | ||
FMLEnvironment.dist.isClient() ? FMLClientSetupEvent::new : FMLDedicatedServerSetupEvent::new); | ||
|
||
ModLoader.get().runInitTask("Registration events", syncExecutor, periodicTask, RegistrationEvents::init); | ||
} | ||
|
||
public static void finish(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable periodicTask) { | ||
if (!ModLoader.isLoadingStateValid()) { | ||
return; | ||
} | ||
|
||
ModLoader.get().dispatchParallelEvent("Enqueue IMC", syncExecutor, parallelExecutor, periodicTask, InterModEnqueueEvent::new); | ||
ModLoader.get().dispatchParallelEvent("Process IMC", syncExecutor, parallelExecutor, periodicTask, InterModProcessEvent::new); | ||
ModLoader.get().dispatchParallelEvent("Complete loading of %d mods".formatted(ModList.get().size()), syncExecutor, parallelExecutor, periodicTask, FMLLoadCompleteEvent::new); | ||
|
||
ModLoader.get().runInitTask("Network registry lock", syncExecutor, periodicTask, NetworkRegistry.getInstance()::setup); | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
src/main/java/net/neoforged/neoforge/internal/NeoForgeStatesProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/main/resources/META-INF/services/net.neoforged.fml.IModStateProvider
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters