Fix up event naming, move them to sensible packages and document everything a bit.

This commit is contained in:
cpw committed 2019-01-14 22:43:17 -05:00
1 parent 220bf8730a
commit 56a3926b86
95 files changed
+333 -251

No files matched your search

@@ -45,6 +45,42 @@ import java.util.stream.Stream;
import static net.minecraftforge.fml.Logging.CORE;
import static net.minecraftforge.fml.Logging.LOADING;
/**
* Loads mods.
*
* Dispatch cycle is seen in {@link #loadMods()} and {@link #finishMods()}
*
* Overall sequence for loadMods is:
* <dl>
* <dt>CONSTRUCT</dt>
* <dd>Constructs the mod instance. Mods can typically setup basic environment such as Event listeners
* and Configuration specifications here.</dd>
* <dt>Automated dispatches</dt>
* <dd>Dispatches automated elements : {@link net.minecraftforge.fml.common.Mod.EventBusSubscriber},
* {@link net.minecraftforge.event.RegistryEvent}, {@link net.minecraftforge.common.capabilities.CapabilityInject}
* and others</dd>
* <dt>CONFIG_LOAD</dt>
* <dd>Dispatches ConfigLoadEvent to mods</dd>
* <dt>COMMON_SETUP</dt>
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent} to mods</dd>
* <dt>SIDED_SETUP</dt>
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent} or
* {@link net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent} to mods</dd>
* </dl>
*
* Overall sequence for finishMods is:
* <dl>
* <dt>ENQUEUE_IMC</dt>
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent} to mods,
* for enqueuing {@link InterModComms} messages for other mods to receive subsequently</dd>
* <dt>PROCESS_IMC</dt>
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.InterModProcessEvent} to mods,
* for processing {@link InterModComms} messages received from other mods prior to this event</dd>
* <dt>COMPLETE</dt>
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent} to mods,
* and completes the mod loading sequence.</dd>
* </dl>
*/
public class ModLoader
{
private static final Logger LOGGER = LogManager.getLogger();
@@ -91,9 +127,9 @@ public class ModLoader
ObjectHolderRegistry.findObjectHolders();
CapabilityManager.INSTANCE.injectCapabilities(modList.getAllScanData());
GameData.fireRegistryEvents();
dispatchAndHandleError(LifecycleEventProvider.PREINIT);
dispatchAndHandleError(LifecycleEventProvider.SETUP);
DistExecutor.runWhenOn(Dist.CLIENT, ModLoader::fireClientEvents);
dispatchAndHandleError(LifecycleEventProvider.SIDEDINIT);
dispatchAndHandleError(LifecycleEventProvider.SIDED_SETUP);
}
private void dispatchAndHandleError(LifecycleEventProvider event) {
@@ -130,8 +166,8 @@ public class ModLoader
public void finishMods()
{
dispatchAndHandleError(LifecycleEventProvider.INIT);
dispatchAndHandleError(LifecycleEventProvider.POSTINIT);
dispatchAndHandleError(LifecycleEventProvider.ENQUEUE_IMC);
dispatchAndHandleError(LifecycleEventProvider.PROCESS_IMC);
dispatchAndHandleError(LifecycleEventProvider.COMPLETE);
GameData.freezeData();
}