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 final List<ModLoadingException>
private final LoadingModList
private boolean
private final List<ModLoadingWarning>
private static final org.apache.logging.log4j.Logger
private ModList
private static boolean
private final ModStateManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addWarning
(ModLoadingWarning warning) private ModContainer
buildModContainerFromTOML
(net.minecraftforge.forgespi.locating.IModFile modFile, Map<String, net.minecraftforge.forgespi.language.IModInfo> modInfoMap, Map.Entry<String, ? extends net.minecraftforge.forgespi.language.IModLanguageProvider.IModLanguageLoader> idToProviderEntry) private List<ModContainer>
buildMods
(net.minecraftforge.forgespi.locating.IModFile modFile) 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>
TpostEventWithReturn
(T e) <T extends net.minecraftforge.eventbus.api.Event & IModBusEvent>
voidpostEventWithWrapInModOrder
(T e, BiConsumer<ModContainer, T> pre, BiConsumer<ModContainer, T> post) <T extends net.minecraftforge.eventbus.api.Event & IModBusEvent>
voidrunEventGenerator
(Function<ModContainer, T> generator) private void
waitForTransition
(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Runnable ticker, CompletableFuture<Void> 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<Void> transition) -
buildMods
-
buildModContainerFromTOML
private ModContainer buildModContainerFromTOML(net.minecraftforge.forgespi.locating.IModFile modFile, 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
-
postEventWithReturn
-
postEventWithWrapInModOrder
public <T extends net.minecraftforge.eventbus.api.Event & IModBusEvent> void postEventWithWrapInModOrder(T e, BiConsumer<ModContainer, T> pre, BiConsumer<ModContainer, T> post) -
getWarnings
-
addWarning
-
isDataGenRunning
public static boolean isDataGenRunning()
-