diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java index 1530f6b575..95b3007dec 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java @@ -39,6 +39,7 @@ public class FMLConfig EARLY_WINDOW_SQUIR("earlyWindowSquir", Boolean.FALSE, "Squir?"), EARLY_WINDOW_SHOW_CPU("earlyWindowShowCPU", Boolean.FALSE, "Whether to show CPU usage stats in early window"), EARLY_WINDOW_LOG_HELP_MSG("earlyWindowLogHelpMessage", Boolean.TRUE, "Whether to log a help message on first attempt, to aid troubleshooting. This setting should automatically disable itself after a successful launch"), + DETECT_NON_FORGE_MODS_TOML("detectNonForgeModsToml", Boolean.TRUE, "Attempt to detect non-Forge mods from their mods.toml to show a friendlier error message. This is a best-effort feature - disable if it causes issues."), ; private final String entry; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java index be4e6704df..800b064fae 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java @@ -50,7 +50,7 @@ public abstract class AbstractModProvider implements IModProvider { if (sj.moduleDataProvider().findFile(MODS_TOML).isPresent()) { LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path); mod = new ModFile(sj, this, ModFileParser::modsTomlParser); - if (mod.getModFileInfo().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) { + if (ModFileInfo.DETECT_NON_FORGE_MODS_TOML && mod.getModFileInfo().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) { LOGGER.error(LogMarkers.SCAN, "Unable to load file \"{}\" because its mods.toml is requesting an invalid javafml loaderVersion (use \"*\" if you want to allow all versions) and is missing a forge modId dependency declaration (see the sample mods.toml in the MDK).", path); return new IModLocator.ModFileOrException(null, new ModFileLoadingException("File \"%s\" is not a Forge mod and cannot be loaded. Look for a Forge version of this mod or consider alternative mods.".formatted(mod.getFileName()))); } diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java index 0dc3119eaf..8ca625fd19 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java @@ -8,6 +8,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.google.common.base.Strings; import com.mojang.logging.LogUtils; import cpw.mods.modlauncher.api.LamdbaExceptionUtils; +import net.minecraftforge.fml.loading.FMLConfig; import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.StringUtils; import net.minecraftforge.forgespi.language.IConfigurable; @@ -48,6 +49,9 @@ public class ModFileInfo implements IModFileInfo, IConfigurable @ApiStatus.Internal public static final String NOT_A_FORGE_MOD_PROP = "__FORGE__not_a_forge_mod"; + @ApiStatus.Internal + public static final boolean DETECT_NON_FORGE_MODS_TOML = FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.DETECT_NON_FORGE_MODS_TOML); + private final IConfigurable config; private final ModFile modFile; private final URL issueURL; @@ -75,7 +79,8 @@ public class ModFileInfo implements IModFileInfo, IConfigurable this.languageSpecs = new ArrayList<>(List.of(new LanguageSpec(modLoader, modLoaderVersion))); // if true, this might not be a Forge mod - boolean maybeNotAForgeMod = modLoader.equals(JAVAFML) + boolean maybeNotAForgeMod = DETECT_NON_FORGE_MODS_TOML + && modLoader.equals(JAVAFML) && modLoaderVersion.hasRestrictions() // if loaderVersion is not "*" && modLoaderVerStr.equals(MAYBE_NOT_JAVAFML_VER); // if loaderVersion is exactly "[2,)" diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java index b725bd331d..4436adf4e0 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java @@ -214,7 +214,7 @@ public class ModInfo implements IModInfo, IConfigurable { this.owner = owner; this.modId = config.getConfigElement("modId") .orElseThrow(()->new InvalidModFileException("Missing required field modid in dependency", getOwningFile())); - if (this.modId.equals("forge")) { + if (ModFileInfo.DETECT_NON_FORGE_MODS_TOML && this.modId.equals("forge")) { var fileProps = owner.getOwningFile().getFileProperties(); // Checking containsKey to avoid a possible exception if the property is not present (due to Collections.emptyMap()) if (!fileProps.isEmpty() && fileProps.containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) { @@ -226,7 +226,7 @@ public class ModInfo implements IModInfo, IConfigurable { var mandatory = config.getConfigElement("mandatory"); if (mandatory.isPresent()) { this.mandatory = mandatory.get(); - } else if (owner.getOwningFile().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) { + } else if (ModFileInfo.DETECT_NON_FORGE_MODS_TOML && owner.getOwningFile().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) { this.mandatory = true; } else { throw new InvalidModFileException("Missing required field mandatory in dependency", getOwningFile()); diff --git a/settings.gradle b/settings.gradle index ab970ae39e..db2c497220 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,3 @@ -import org.gradle.internal.os.OperatingSystem - pluginManagement { repositories { gradlePluginPortal()