Package net.minecraftforge.fml
Class ModLoader
java.lang.Object
net.minecraftforge.fml.ModLoader
Loads mods.
Dispatch cycle is seen in
#loadMods()
and #finishMods()
Overall sequence for loadMods is:
- CONSTRUCT
- Constructs the mod instance. Mods can typically setup basic environment such as Event listeners and Configuration specifications here.
- Automated dispatches
- Dispatches automated elements :
Mod.EventBusSubscriber
,RegistryEvent
,CapabilityInject
and others - CONFIG_LOAD
- Dispatches ConfigLoadEvent to mods
- COMMON_SETUP
- Dispatches
FMLCommonSetupEvent
to mods - SIDED_SETUP
- Dispatches
FMLClientSetupEvent
orFMLDedicatedServerSetupEvent
to mods
- ENQUEUE_IMC
- Dispatches
InterModEnqueueEvent
to mods, for enqueuingInterModComms
messages for other mods to receive subsequently - PROCESS_IMC
- Dispatches
InterModProcessEvent
to mods, for processingInterModComms
messages received from other mods prior to this event - COMPLETE
- Dispatches
FMLLoadCompleteEvent
to mods, and completes the mod loading sequence.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprivate static ModLoader
private final cpw.mods.modlauncher.TransformingClassLoader
private final List<ModLoadingException>
private final LoadingModList
private boolean
private final List<ModLoadingWarning>
private static final org.apache.logging.log4j.Logger
private static boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addWarning
(ModLoadingWarning warning) private ModContainer
buildModContainerFromTOML
(ModFile modFile, cpw.mods.modlauncher.TransformingClassLoader modClassLoader, Map<String, net.minecraftforge.forgespi.language.IModInfo> modInfoMap, Map.Entry<String, ? extends net.minecraftforge.forgespi.language.IModLanguageProvider.IModLanguageLoader> idToProviderEntry) private List<ModContainer>
private String
private String
private void
dispatchAndHandleError
(ModLoadingStage state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable ticker) private void
dispatchAndHandleError
(ModLoadingStage state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable ticker, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) void
finishMods
(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable periodicTask) void
gatherAndInitializeMods
(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable periodicTask) Run on the primary starting thread by ClientModLoader and ServerModLoaderstatic ModLoader
get()
static boolean
static boolean
void
loadMods
(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> beforeSidedEvent, Function<Executor, CompletableFuture<Void>> afterSidedEvent, Runnable periodicTask) <T extends net.minecraftforge.eventbus.api.Event & IModBusEvent>
voidpostEvent
(T e) <T extends net.minecraftforge.eventbus.api.Event & IModBusEvent>
voidrunEventGenerator
(Function<ModContainer, T> generator) private void
waitForTransition
(ModLoadingStage state, ModWorkManager.DrivenExecutor syncExecutor, Runnable ticker, CompletableFuture<List<Throwable>> transition)
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
INSTANCE
-
launchClassLoader
private final cpw.mods.modlauncher.TransformingClassLoader launchClassLoader -
loadingModList
-
loadingExceptions
-
loadingWarnings
-
loadingStateValid
private boolean loadingStateValid -
statusConsumer
-
runningDataGen
private static boolean runningDataGen
-
-
Constructor Details
-
ModLoader
private ModLoader()
-
-
Method Details
-
computeLanguageList
-
computeModLauncherServiceList
-
get
-
gatherAndInitializeMods
public void gatherAndInitializeMods(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable periodicTask) Run on the primary starting thread by ClientModLoader and ServerModLoader- Parameters:
syncExecutor
- An executor to run tasks on the main threadparallelExecutor
- An executor to run tasks on a parallel loading thread poolperiodicTask
- Optional periodic task to perform on the main thread while other activities run
-
loadMods
public void loadMods(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> beforeSidedEvent, Function<Executor, CompletableFuture<Void>> afterSidedEvent, Runnable periodicTask) -
finishMods
public void finishMods(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable periodicTask) -
dispatchAndHandleError
private void dispatchAndHandleError(ModLoadingStage state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable ticker) -
dispatchAndHandleError
private void dispatchAndHandleError(ModLoadingStage state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable ticker, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) -
waitForTransition
private void waitForTransition(ModLoadingStage state, ModWorkManager.DrivenExecutor syncExecutor, Runnable ticker, CompletableFuture<List<Throwable>> transition) -
buildMods
private List<ModContainer> buildMods(ModFile modFile, cpw.mods.modlauncher.TransformingClassLoader modClassLoader) -
buildModContainerFromTOML
private ModContainer buildModContainerFromTOML(ModFile modFile, cpw.mods.modlauncher.TransformingClassLoader modClassLoader, Map<String, net.minecraftforge.forgespi.language.IModInfo> modInfoMap, Map.Entry<String, ? extends net.minecraftforge.forgespi.language.IModLanguageProvider.IModLanguageLoader> idToProviderEntry) -
isLoadingStateValid
public static boolean isLoadingStateValid()- Returns:
- If the current mod loading state is valid. Use if you interact with vanilla systems directly during loading and don't want to cause extraneous crashes due to trying to do things that aren't possible in a "broken load"
-
runEventGenerator
public <T extends net.minecraftforge.eventbus.api.Event & IModBusEvent> void runEventGenerator(Function<ModContainer, T> generator) -
postEvent
-
getWarnings
-
addWarning
-
isDataGenRunning
public static boolean isDataGenRunning()
-