-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to simpler mod loading from latest FML
- Loading branch information
1 parent
916bfcb
commit f845000
Showing
12 changed files
with
112 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/main/java/net/neoforged/neoforge/internal/CommonModLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.internal; | ||
|
||
import java.util.concurrent.Executor; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.fml.ModList; | ||
import net.neoforged.fml.ModLoader; | ||
import net.neoforged.fml.ModWorkManager; | ||
import net.neoforged.fml.config.ConfigTracker; | ||
import net.neoforged.fml.config.ModConfig; | ||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; | ||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent; | ||
import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent; | ||
import net.neoforged.fml.event.lifecycle.InterModEnqueueEvent; | ||
import net.neoforged.fml.event.lifecycle.InterModProcessEvent; | ||
import net.neoforged.fml.loading.FMLEnvironment; | ||
import net.neoforged.fml.loading.FMLPaths; | ||
import net.neoforged.neoforge.network.registration.NetworkRegistry; | ||
import net.neoforged.neoforge.registries.GameData; | ||
import net.neoforged.neoforge.registries.RegistryManager; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
/** | ||
* Internal class for handling the steps of mod loading that are common for client, data and server runs. | ||
*/ | ||
@ApiStatus.Internal | ||
public abstract class CommonModLoader { | ||
private static boolean registriesLoaded = false; | ||
|
||
public static boolean areRegistriesLoaded() { | ||
return registriesLoaded; | ||
} | ||
|
||
protected static void begin(Runnable periodicTask) { | ||
var syncExecutor = ModWorkManager.syncExecutor(); | ||
|
||
ModLoader.get().gatherAndInitializeMods(syncExecutor, ModWorkManager.parallelExecutor(), periodicTask); | ||
|
||
ModLoader.get().runInitTask("Registry initialization", syncExecutor, periodicTask, () -> { | ||
RegistryManager.postNewRegistryEvent(); | ||
GameData.unfreezeData(); | ||
GameData.postRegisterEvents(); | ||
GameData.freezeData(); | ||
registriesLoaded = true; | ||
}); | ||
} | ||
|
||
protected static void load(Executor syncExecutor, Executor parallelExecutor) { | ||
Runnable periodicTask = () -> {}; // no need to pass something else for now | ||
|
||
if (!ModLoader.isLoadingStateValid()) { | ||
return; | ||
} | ||
|
||
ModLoader.get().runInitTask("Config loading", syncExecutor, periodicTask, () -> { | ||
if (FMLEnvironment.dist == Dist.CLIENT) { | ||
ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.CLIENT, FMLPaths.CONFIGDIR.get()); | ||
} | ||
ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.COMMON, FMLPaths.CONFIGDIR.get()); | ||
}); | ||
|
||
ModLoader.get().dispatchParallelEvent("Common setup", syncExecutor, parallelExecutor, periodicTask, FMLCommonSetupEvent::new); | ||
ModLoader.get().dispatchParallelEvent("Sided setup", syncExecutor, parallelExecutor, periodicTask, | ||
FMLEnvironment.dist.isClient() ? FMLClientSetupEvent::new : FMLDedicatedServerSetupEvent::new); | ||
|
||
ModLoader.get().runInitTask("Registration events", syncExecutor, periodicTask, RegistrationEvents::init); | ||
} | ||
|
||
protected static void finish(Executor syncExecutor, Executor parallelExecutor) { | ||
Runnable periodicTask = () -> {}; // no need to pass something else for now | ||
|
||
if (!ModLoader.isLoadingStateValid()) { | ||
return; | ||
} | ||
|
||
ModLoader.get().dispatchParallelEvent("Enqueue IMC", syncExecutor, parallelExecutor, periodicTask, InterModEnqueueEvent::new); | ||
ModLoader.get().dispatchParallelEvent("Process IMC", syncExecutor, parallelExecutor, periodicTask, InterModProcessEvent::new); | ||
ModLoader.get().dispatchParallelEvent("Complete loading of %d mods".formatted(ModList.get().size()), syncExecutor, parallelExecutor, periodicTask, FMLLoadCompleteEvent::new); | ||
|
||
ModLoader.get().runInitTask("Network registry lock", syncExecutor, periodicTask, NetworkRegistry.getInstance()::setup); | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
src/main/java/net/neoforged/neoforge/internal/NeoForgeStatesProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/main/resources/META-INF/services/net.neoforged.fml.IModStateProvider
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters