mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
Cleanup lifecycle transitions
Fix mod ordering for multi-mod jars Make dependency resolution issues easier to debug/diagnose
This commit is contained in:
22 files changed
+828
-569
No files matched your search
@@ -11,22 +11,39 @@ import net.minecraftforge.fml.IModLoadingState;
|
||||
import net.minecraftforge.fml.IModStateProvider;
|
||||
import net.minecraftforge.fml.ModLoadingPhase;
|
||||
import net.minecraftforge.fml.ModLoadingState;
|
||||
import net.minecraftforge.fml.core.ModStateProvider;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
import net.minecraftforge.registries.ObjectHolderRegistry;
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
|
||||
public class ForgeStatesProvider implements IModStateProvider {
|
||||
final ModLoadingState CREATE_REGISTRIES = ModLoadingState.withInline("CREATE_REGISTRIES", "CONSTRUCT", ModLoadingPhase.GATHER, ml -> RegistryManager.postNewRegistryEvent());
|
||||
final ModLoadingState OBJECT_HOLDERS = ModLoadingState.withInline("OBJECT_HOLDERS", "CREATE_REGISTRIES", ModLoadingPhase.GATHER, ml -> ObjectHolderRegistry.findObjectHolders());
|
||||
final ModLoadingState INJECT_CAPABILITIES = ModLoadingState.withInline("INJECT_CAPABILITIES", "OBJECT_HOLDERS", ModLoadingPhase.GATHER, CapabilityManager::injectCapabilities);
|
||||
final ModLoadingState UNFREEZE = ModLoadingState.withInline("UNFREEZE_DATA", "INJECT_CAPABILITIES", ModLoadingPhase.GATHER, ml -> GameData.unfreezeData());
|
||||
final ModLoadingState LOAD_REGISTRIES = ModLoadingState.withInline("LOAD_REGISTRIES", "UNFREEZE_DATA", ModLoadingPhase.GATHER, ml -> GameData.postRegisterEvents());
|
||||
final ModLoadingState FREEZE = ModLoadingState.withInline("FREEZE_DATA", "COMPLETE", ModLoadingPhase.COMPLETE, ml -> GameData.freezeData());
|
||||
final ModLoadingState NETLOCK = ModLoadingState.withInline("NETWORK_LOCK", "FREEZE_DATA", ModLoadingPhase.COMPLETE, ml -> NetworkRegistry.lock());
|
||||
public static final ModLoadingState CREATE_REGISTRIES = gather("CREATE_REGISTRIES", ModStateProvider.CONSTRUCT, RegistryManager::postNewRegistryEvent);
|
||||
public static final ModLoadingState OBJECT_HOLDERS = gather("OBJECT_HOLDERS", CREATE_REGISTRIES, ObjectHolderRegistry::findObjectHolders);
|
||||
public static final ModLoadingState INJECT_CAPABILITIES = gather("INJECT_CAPABILITIES", OBJECT_HOLDERS).withInline(CapabilityManager::injectCapabilities);
|
||||
public static final ModLoadingState UNFREEZE_DATA = gather("UNFREEZE_DATA", INJECT_CAPABILITIES, GameData::unfreezeData);
|
||||
public static final ModLoadingState LOAD_REGISTRIES = gather("LOAD_REGISTRIES", UNFREEZE_DATA, GameData::postRegisterEvents);
|
||||
public static final ModLoadingState FREEZE_DATA = complete("FREEZE_DATA", ModStateProvider.COMPLETE, GameData::freezeData);
|
||||
public static final ModLoadingState NETWORK_LOCK = complete("NETWORK_LOCK", FREEZE_DATA, NetworkRegistry::lock);
|
||||
|
||||
private static ModLoadingState.Builder gather(String name, ModLoadingState after) {
|
||||
return ModLoadingState.of(name, ModLoadingPhase.GATHER).after(after);
|
||||
}
|
||||
|
||||
private static ModLoadingState gather(String name, ModLoadingState after, Runnable inline) {
|
||||
return gather(name, after).withInline(ml -> inline.run());
|
||||
}
|
||||
|
||||
private static ModLoadingState.Builder complete(String name, ModLoadingState after) {
|
||||
return ModLoadingState.of(name, ModLoadingPhase.COMPLETE).after(after);
|
||||
}
|
||||
|
||||
private static ModLoadingState complete(String name, ModLoadingState after, Runnable inline) {
|
||||
return complete(name, after).withInline(ml -> inline.run());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IModLoadingState> getAllStates() {
|
||||
return List.of(CREATE_REGISTRIES, OBJECT_HOLDERS, INJECT_CAPABILITIES, UNFREEZE, LOAD_REGISTRIES, FREEZE, NETLOCK);
|
||||
return List.of(CREATE_REGISTRIES, OBJECT_HOLDERS, INJECT_CAPABILITIES, UNFREEZE_DATA, LOAD_REGISTRIES, FREEZE_DATA, NETWORK_LOCK);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user