diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java index 08e3275b58..9bddd9c26c 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java @@ -6,6 +6,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.mojang.logging.LogUtils; +import cpw.mods.jarhandling.SecureJar; import cpw.mods.modlauncher.api.IModuleLayerManager; import cpw.mods.modlauncher.api.ITransformationService; import net.minecraftforge.fml.loading.*; @@ -26,14 +27,17 @@ public class ModValidator { private final Map> modFiles; private final List candidatePlugins; private final List candidateMods; + private final List gameLibraries; private LoadingModList loadingModList; - private List brokenFiles; + private final List brokenFiles; private final List discoveryErrorData; public ModValidator(final Map> modFiles, final List brokenFiles, final List discoveryErrorData) { this.modFiles = modFiles; this.candidateMods = lst(modFiles.get(IModFile.Type.MOD)); this.candidateMods.addAll(lst(modFiles.get(IModFile.Type.GAMELIBRARY))); + this.gameLibraries = lst(modFiles.get(IModFile.Type.GAMELIBRARY)); + this.candidateMods.addAll(this.gameLibraries); this.candidatePlugins = lst(modFiles.get(IModFile.Type.LANGPROVIDER)); this.candidatePlugins.addAll(lst(modFiles.get(IModFile.Type.LIBRARY))); this.discoveryErrorData = discoveryErrorData; @@ -55,8 +59,7 @@ public class ModValidator { @NotNull private List validateFiles(final List mods) { final List brokenFiles = new ArrayList<>(); - for (Iterator iterator = mods.iterator(); iterator.hasNext(); ) - { + for (Iterator iterator = mods.iterator(); iterator.hasNext();) { ModFile modFile = iterator.next(); if (!modFile.getProvider().isValid(modFile) || !modFile.identifyMods()) { LOGGER.warn(LogMarkers.SCAN, "File {} has been ignored - it is invalid", modFile.getFilePath()); @@ -72,7 +75,26 @@ public class ModValidator { } public ITransformationService.Resource getModResources() { - return new ITransformationService.Resource(IModuleLayerManager.Layer.GAME, this.candidateMods.stream().map(IModFile::getSecureJar).toList()); + var mods = new ArrayList(); + // Add only the valid mods that we will be attempting to load. + // If any detectable error happens during the sorting process {missing deps, duplicates, + // This helps prevent coremods/mixins from screwing up us displaying the error screens that the sorting/validation is trying to display. + // This won't fix them all as they are still loaded and will still apply but it might help + for (var info : this.loadingModList.getModFiles()) + mods.add(info.getFile().getSecureJar()); + + // Add any game libraries, this *may* be duplicates, depending on the state of the sorting. But until I get around to re-writing + // that clusterfuck of a system, have this simple de-duplication. Order of resource is important, but i'm unsure if duplication is + // so might as well waste a few cycles on checking. Still faster then converting from a set to a list. + // Ideally we would explicitly list out which mods to load {forge and MC being the only ones} but some coremods could require extra things. + // So try game libraries as well + for (var lib : this.gameLibraries) { + var jar = lib.getSecureJar(); + if (!mods.contains(jar)) + mods.add(jar); + } + + return new ITransformationService.Resource(IModuleLayerManager.Layer.GAME, mods); } private List validateLanguages() { diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index 235e1b55d1..3cdaccbe3e 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -512,7 +512,7 @@ public class ForgeHooksClient public static void fillNormal(int[] faceData, Direction facing, boolean calculateNormals) { Vector3f v2; - if (calculateNormals || ForgeConfig.CLIENT.calculateAllNormals.get()) { + if (calculateNormals || ForgeConfig.CLIENT.calculateAllNormals()) { Vector3f v1 = getVertexPos(faceData, 3); Vector3f t1 = getVertexPos(faceData, 1); v2 = getVertexPos(faceData, 2); diff --git a/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java index 43a9471f8c..e9463132b3 100644 --- a/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java +++ b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java @@ -5,7 +5,6 @@ package net.minecraftforge.client.loading; - import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -119,12 +118,8 @@ public class ClientModLoader public static boolean completeModLoading() { var warnings = ModLoader.get().getWarnings(); - boolean showWarnings = true; - try { - showWarnings = ForgeConfig.CLIENT.showLoadWarnings.get(); - } catch (NullPointerException | IllegalStateException e) { - // We're in an early error state, config is not available. Assume true. - } + boolean showWarnings = ForgeConfig.CLIENT.showLoadWarnings(); + if (!showWarnings) { //User disabled warning screen, as least log them if (!warnings.isEmpty()) { diff --git a/src/main/java/net/minecraftforge/common/ForgeConfig.java b/src/main/java/net/minecraftforge/common/ForgeConfig.java index 0944705bb0..61153442e3 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfig.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfig.java @@ -158,6 +158,16 @@ public class ForgeConfig { builder.pop(); } + + // Allow these to be called before the config is loaded because its used before loading the error screens. + // Prevents a ton of spam when an error screen is displayed. + public final boolean calculateAllNormals() { + return clientSpec.isLoaded() ? calculateAllNormals.get() : calculateAllNormals.getDefault(); + } + + public final boolean showLoadWarnings() { + return clientSpec.isLoaded() ? showLoadWarnings.get() : showLoadWarnings.getDefault(); + } } static final ForgeConfigSpec clientSpec;