From 4d0356eb36d2ed0f185f00fffb5d5cb60ced96a3 Mon Sep 17 00:00:00 2001 From: Matyrobbrt Date: Wed, 20 Mar 2024 08:41:44 +0200 Subject: [PATCH 1/2] Rename mods.toml to neoforge.mods.toml --- loader/src/main/java/net/neoforged/fml/ModLoader.java | 3 ++- .../fml/loading/moddiscovery/AbstractModProvider.java | 2 +- .../fml/loading/moddiscovery/ExplodedDirectoryLocator.java | 2 +- .../neoforged/fml/loading/moddiscovery/ModFileParser.java | 6 +++--- .../fml/loading/targets/CommonDevLaunchHandler.java | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/loader/src/main/java/net/neoforged/fml/ModLoader.java b/loader/src/main/java/net/neoforged/fml/ModLoader.java index 176280e07..2fdcb0212 100644 --- a/loader/src/main/java/net/neoforged/fml/ModLoader.java +++ b/loader/src/main/java/net/neoforged/fml/ModLoader.java @@ -14,6 +14,7 @@ import net.neoforged.fml.loading.FMLLoader; import net.neoforged.fml.loading.ImmediateWindowHandler; import net.neoforged.fml.loading.LoadingModList; +import net.neoforged.fml.loading.moddiscovery.AbstractModProvider; import net.neoforged.fml.loading.moddiscovery.InvalidModIdentifier; import net.neoforged.fml.loading.moddiscovery.ModFileInfo; import net.neoforged.fml.loading.moddiscovery.ModInfo; @@ -277,7 +278,7 @@ private List buildMods(final IModFile modFile) var missingClasses = new ArrayList<>(modIds); missingClasses.removeAll(containerIds); - LOGGER.fatal(LOADING, "The following classes are missing, but are reported in the mods.toml: {}", missingClasses); + LOGGER.fatal(LOADING, "The following classes are missing, but are reported in the {}: {}", AbstractModProvider.MODS_TOML, missingClasses); var missingMods = new ArrayList<>(containerIds); missingMods.removeAll(modIds); diff --git a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/AbstractModProvider.java b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/AbstractModProvider.java index 2553af652..41a27188e 100644 --- a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/AbstractModProvider.java +++ b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/AbstractModProvider.java @@ -29,7 +29,7 @@ public abstract class AbstractModProvider implements IModProvider { private static final Logger LOGGER = LogUtils.getLogger(); - protected static final String MODS_TOML = "META-INF/mods.toml"; + public static final String MODS_TOML = "neoforge.mods.toml"; protected static final String MANIFEST = "META-INF/MANIFEST.MF"; protected IModLocator.ModFileOrException createMod(Path... path) { diff --git a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ExplodedDirectoryLocator.java b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ExplodedDirectoryLocator.java index 0888dc808..fcabd171c 100644 --- a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ExplodedDirectoryLocator.java +++ b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ExplodedDirectoryLocator.java @@ -41,7 +41,7 @@ public List scanMods() { mjm.setModFile(mf); mods.put(explodedMod, mf); } else { - LOGGER.warn(LogMarkers.LOADING, "Failed to find exploded resource mods.toml in directory {}", explodedMod.paths().get(0).toString()); + LOGGER.warn(LogMarkers.LOADING, "Failed to find exploded resource {} in directory {}", AbstractModProvider.MODS_TOML, explodedMod.paths().get(0).toString()); } }); return mods.values().stream().map(mf->new IModLocator.ModFileOrException(mf, null)).toList(); diff --git a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFileParser.java b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFileParser.java index 03a0bad93..0cc620e4e 100644 --- a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFileParser.java +++ b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFileParser.java @@ -34,9 +34,9 @@ public static IModFileInfo readModList(final ModFile modFile, final ModFileFacto public static IModFileInfo modsTomlParser(final IModFile imodFile) { ModFile modFile = (ModFile) imodFile; LOGGER.debug(LogMarkers.LOADING,"Considering mod file candidate {}", modFile.getFilePath()); - final Path modsjson = modFile.findResource("META-INF", "mods.toml"); + final Path modsjson = modFile.findResource(AbstractModProvider.MODS_TOML); if (!Files.exists(modsjson)) { - LOGGER.warn(LogMarkers.LOADING, "Mod file {} is missing mods.toml file", modFile.getFilePath()); + LOGGER.warn(LogMarkers.LOADING, "Mod file {} is missing {} file", modFile.getFilePath(), AbstractModProvider.MODS_TOML); return null; } @@ -106,4 +106,4 @@ protected static Optional> getAccessTransformers(IModFileInfo modFi return Optional.of(List.of()); } } -} \ No newline at end of file +} diff --git a/loader/src/main/java/net/neoforged/fml/loading/targets/CommonDevLaunchHandler.java b/loader/src/main/java/net/neoforged/fml/loading/targets/CommonDevLaunchHandler.java index 55bc5cfbb..47cf690fe 100644 --- a/loader/src/main/java/net/neoforged/fml/loading/targets/CommonDevLaunchHandler.java +++ b/loader/src/main/java/net/neoforged/fml/loading/targets/CommonDevLaunchHandler.java @@ -9,6 +9,7 @@ import cpw.mods.jarhandling.SecureJar; import cpw.mods.niofs.union.UnionPathFilter; import net.neoforged.fml.loading.FileUtils; +import net.neoforged.fml.loading.moddiscovery.AbstractModProvider; import java.nio.file.Path; import java.nio.file.Paths; @@ -119,7 +120,7 @@ protected UnionPathFilter getMcFilter(Path extra, List minecraft, Stream.B } protected String[] getExcludedPrefixes() { - return new String[]{ "net/neoforged/neoforge/", "META-INF/services/", "META-INF/coremods.json", "META-INF/mods.toml" }; + return new String[]{ "net/neoforged/neoforge/", "META-INF/services/", "META-INF/coremods.json", AbstractModProvider.MODS_TOML}; } private static String getRandomNumbers(int length) { From 737381c42b5ddd9767cd3e7a679946592f4d02f7 Mon Sep 17 00:00:00 2001 From: Matyrobbrt Date: Thu, 21 Mar 2024 21:21:48 +0200 Subject: [PATCH 2/2] Use the metainf dir I love forgetting to push... --- .../neoforged/fml/loading/moddiscovery/AbstractModProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/AbstractModProvider.java b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/AbstractModProvider.java index 41a27188e..a964f4f17 100644 --- a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/AbstractModProvider.java +++ b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/AbstractModProvider.java @@ -29,7 +29,7 @@ public abstract class AbstractModProvider implements IModProvider { private static final Logger LOGGER = LogUtils.getLogger(); - public static final String MODS_TOML = "neoforge.mods.toml"; + public static final String MODS_TOML = "META-INF/neoforge.mods.toml"; protected static final String MANIFEST = "META-INF/MANIFEST.MF"; protected IModLocator.ModFileOrException createMod(Path... path) {