Optionally supply FMLJavaModLoadingContext as a param to mod constructors (backport of #10074 to 1.20.4) (#10099)

Co-authored-by: RealMangoRage <[email protected]>
This commit is contained in:
Paint_NinjaandRealMangoRage authored and GitHub committed 2024-09-12 14:03:01 +01:00
1 parent dd866ed53e
commit d0fea9cf76
7 files changed
+60 -35

No files matched your search

@@ -389,7 +389,7 @@ public class ForgeMod {
enableMilkFluid = true;
}
public ForgeMod() {
public ForgeMod(FMLJavaModLoadingContext context) {
LOGGER.info(FORGEMOD,"Forge mod loading, version {}, for MC {} with MCP {}", ForgeVersion.getVersion(), MCPVersion.getMCVersion(), MCPVersion.getMCPVersion());
INSTANCE = this;
MinecraftForge.initialize();
@@ -406,7 +406,7 @@ public class ForgeMod {
CrashReportCallables.registerCrashCallable("FML", ForgeVersion::getSpec);
CrashReportCallables.registerCrashCallable("Forge", ()->ForgeVersion.getGroup()+":"+ForgeVersion.getVersion());
final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
final IEventBus modEventBus = context.getModEventBus();
// Forge-provided datapack registries
modEventBus.addListener((DataPackRegistryEvent.NewRegistry event) -> {
event.dataPackRegistry(ForgeRegistries.Keys.BIOME_MODIFIERS, BiomeModifier.DIRECT_CODEC);
@@ -421,13 +421,13 @@ public class ForgeMod {
registries.forEach(r -> r.register(modEventBus));
MinecraftForge.EVENT_BUS.addListener(this::serverStopping);
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec);
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ForgeConfig.serverSpec);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ForgeConfig.commonSpec);
context.registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec);
context.registerConfig(ModConfig.Type.SERVER, ForgeConfig.serverSpec);
context.registerConfig(ModConfig.Type.COMMON, ForgeConfig.commonSpec);
modEventBus.register(ForgeConfig.class);
ForgeDeferredRegistriesSetup.setup(modEventBus);
// Forge does not display problems when the remote is not matching.
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, ()->new IExtensionPoint.DisplayTest(()->"ANY", (remote, isServer)-> true));
context.registerDisplayTest(IExtensionPoint.DisplayTest.IGNORE_ALL_VERSION);
StartupMessageManager.addModMessage("Forge version "+ForgeVersion.getVersion());
MinecraftForge.EVENT_BUS.addListener(VillagerTradingManager::loadTrades);
@@ -31,12 +31,10 @@ import java.util.function.Supplier;
public class MinecraftForge
{
/**
* The core Forge EventBusses, all events for Forge will be fired on these,
* you should use this to register all your listeners.
* This replaces every register*Handler() function in the old version of Forge.
* TERRAIN_GEN_BUS for terrain gen events
* ORE_GEN_BUS for ore gen events
* EVENT_BUS for everything else
* The EventBus for all the Forge Events.
*
* Events marked with {@link net.minecraftforge.fml.event.IModBusEvent}
* belong on the ModBus and not this bus
*/
public static final IEventBus EVENT_BUS = BusBuilder.builder().startShutdown().useModLauncher().build();