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.CapabilityInjectand others - CONFIG_LOAD
- Dispatches ConfigLoadEvent to mods
- COMMON_SETUP
- Dispatches
net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEventto mods - SIDED_SETUP
- Dispatches
net.minecraftforge.fml.event.lifecycle.FMLClientSetupEventornet.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEventto mods
- ENQUEUE_IMC
- Dispatches
net.minecraftforge.fml.event.lifecycle.InterModEnqueueEventto mods, for enqueuingInterModCommsmessages for other mods to receive subsequently - PROCESS_IMC
- Dispatches
net.minecraftforge.fml.event.lifecycle.InterModProcessEventto mods, for processingInterModCommsmessages received from other mods prior to this event - COMPLETE
- Dispatches
net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEventto mods, and completes the mod loading sequence.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set<IModLoadingState>private static ModLoaderprivate final List<ModLoadingException>private final LoadingModListprivate booleanprivate final List<ModLoadingWarning>private static final org.apache.logging.log4j.Loggerprivate ModListprivate static booleanprivate final ModStateManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWarning(ModLoadingWarning warning) private ModContainerbuildModContainerFromTOML(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 Stringprivate Stringprivate voiddispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable ticker) private voiddispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable ticker, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) voidfinishMods(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable periodicTask) voidgatherAndInitializeMods(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, Runnable periodicTask) Run on the primary starting thread by ClientModLoader and ServerModLoaderstatic ModLoaderget()booleanhasCompletedState(String stateName) static booleanstatic booleanvoidloadMods(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>
voidpostEventWrapContainerInModOrder(T event) <T extends net.minecraftforge.eventbus.api.Event & IModBusEvent>
voidrunEventGenerator(Function<ModContainer, T> generator) private voidwaitForTransition(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
-
completedStates
-
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"
-
hasCompletedState
-
runEventGenerator
public <T extends net.minecraftforge.eventbus.api.Event & IModBusEvent> void runEventGenerator(Function<ModContainer, T> generator) -
postEvent
-
postEventWithReturn
-
postEventWrapContainerInModOrder
public <T extends net.minecraftforge.eventbus.api.Event & IModBusEvent> void postEventWrapContainerInModOrder(T event) -
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()
-