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 :
net.minecraftforge.fml.common.Mod.EventBusSubscriber
,net.minecraftforge.event.RegistryEvent
,net.minecraftforge.common.capabilities.CapabilityInject
and others - CONFIG_LOAD
- Dispatches ConfigLoadEvent to mods
- COMMON_SETUP
- Dispatches
net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent
to mods - SIDED_SETUP
- Dispatches
net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
ornet.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent
to mods
- ENQUEUE_IMC
- Dispatches
net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent
to mods, for enqueuingInterModComms
messages for other mods to receive subsequently - PROCESS_IMC
- Dispatches
net.minecraftforge.fml.event.lifecycle.InterModProcessEvent
to mods, for processingInterModComms
messages received from other mods prior to this event - COMPLETE
- Dispatches
net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent
to mods, and completes the mod loading sequence.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprivate static ModLoader
private List<ModLoadingException>
private LoadingModList
private boolean
private List<ModLoadingWarning>
private static org.apache.logging.log4j.Logger
private ModList
private static boolean
private ModStateManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addWarning(ModLoadingWarning warning)
private ModContainer
buildModContainerFromTOML(ModFile modFile, 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(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable ticker)
private void
dispatchAndHandleError(IModLoadingState 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, 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(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Runnable ticker, CompletableFuture<List<Throwable>> transition)
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
INSTANCE
-
loadingModList
-
loadingExceptions
-
loadingWarnings
-
stateManager
-
loadingStateValid
private boolean loadingStateValid -
statusConsumer
-
modList
-
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, Runnable periodicTask) -
finishMods
public void finishMods(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable periodicTask) -
dispatchAndHandleError
private void dispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable ticker) -
dispatchAndHandleError
private void dispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable ticker, Function<Executor,CompletableFuture<Void>> preSyncTask, Function<Executor,CompletableFuture<Void>> postSyncTask) -
waitForTransition
private void waitForTransition(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Runnable ticker, CompletableFuture<List<Throwable>> transition) -
buildMods
-
buildModContainerFromTOML
-
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()
-