diff --git a/loader/src/main/java/net/neoforged/fml/ModList.java b/loader/src/main/java/net/neoforged/fml/ModList.java index 3ecc54e47..8c309a34e 100644 --- a/loader/src/main/java/net/neoforged/fml/ModList.java +++ b/loader/src/main/java/net/neoforged/fml/ModList.java @@ -62,7 +62,7 @@ private String fileToLine(IModFile mf) { } private String crashReport() { - return "\n" + applyForEachModFile(this::fileToLine).collect(Collectors.joining("\n\t\t", "\t\t", "")); + return "\n" + applyForEachModFileAlphabetical(this::fileToLine).collect(Collectors.joining("\n\t\t", "\t\t", "")); } public static ModList of(List modFiles, List sortedList) { @@ -152,6 +152,16 @@ public Stream applyForEachModFile(Function function) { return modFiles.stream().map(IModFileInfo::getFile).map(function); } + /** + * Stream sorted by Mod Name in alphabetical order + */ + public Stream applyForEachModFileAlphabetical(Function function) { + return modFiles.stream() + .map(IModFileInfo::getFile) + .sorted(Comparator.comparing(modFile -> modFile.getModInfos().getFirst().getDisplayName(), String.CASE_INSENSITIVE_ORDER)) + .map(function); + } + public void forEachModContainer(BiConsumer modContainerConsumer) { indexedMods.forEach(modContainerConsumer); } diff --git a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModDiscoverer.java b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModDiscoverer.java index f061cd0ee..08bfb1890 100644 --- a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModDiscoverer.java +++ b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModDiscoverer.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -129,6 +130,8 @@ public ModValidator discoverMods() { LOGGER.error(LogMarkers.SCAN, "Mod Discovery failed. Skipping dependency discovery."); } + LOGGER.info("\n Mod List:\n\t\tName Version (Mod Id)\n\n{}", logReport(modFilesMap.values())); + //Validate the loading. With a deduplicated list, we can now successfully process the artifacts and load //transformer plugins. var validator = new ModValidator(modFilesMap, discoveryIssues); @@ -136,6 +139,24 @@ public ModValidator discoverMods() { return validator; } + private String logReport(Collection> modFiles) { + return modFiles.stream() + .flatMap(Collection::stream) + .filter(modFile -> !modFile.getModInfos().isEmpty()) + .sorted(Comparator.comparing(modFile -> modFile.getModInfos().getFirst().getDisplayName(), String.CASE_INSENSITIVE_ORDER)) + .map(this::fileToLine) + .collect(Collectors.joining("\n\t\t", "\t\t", "")); + } + + private String fileToLine(IModFile mf) { + var mainMod = mf.getModInfos().getFirst(); + + return String.format(Locale.ENGLISH, "%s %s (%s)", + mainMod.getDisplayName(), + mainMod.getVersion(), + mainMod.getModId()); + } + private class DiscoveryPipeline implements IDiscoveryPipeline { private final ModFileDiscoveryAttributes defaultAttributes; private final List loadedFiles;