From 3c006c4ca463ca6a1090494af084962ae1a4044a Mon Sep 17 00:00:00 2001 From: gegy1000 Date: Sat, 16 Feb 2019 10:46:21 +0200 Subject: [PATCH] Fix lazy ModContainer evaluation skipping thrown loadingExceptions Fix formatting --- src/main/java/net/minecraftforge/fml/ModLoader.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/minecraftforge/fml/ModLoader.java b/src/main/java/net/minecraftforge/fml/ModLoader.java index 22dd27697..473b61ca9 100644 --- a/src/main/java/net/minecraftforge/fml/ModLoader.java +++ b/src/main/java/net/minecraftforge/fml/ModLoader.java @@ -26,16 +26,15 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.fml.config.ConfigTracker; import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.loading.FMLPaths; -import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.LoadingModList; import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; +import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.IModLanguageProvider; import net.minecraftforge.registries.GameData; import net.minecraftforge.registries.ObjectHolderRegistry; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -45,7 +44,6 @@ import java.util.Map; import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; -import java.util.stream.Stream; import static net.minecraftforge.fml.Logging.CORE; import static net.minecraftforge.fml.Logging.LOADING; @@ -118,15 +116,16 @@ public class ModLoader if (!this.loadingExceptions.isEmpty()) { throw new LoadingFailedException(loadingExceptions); } - final Stream modContainerStream = loadingModList.getModFiles().stream(). + final List modContainers = loadingModList.getModFiles().stream(). map(ModFileInfo::getFile). map(mf -> buildMods(mf, launchClassLoader)). - flatMap(Collection::stream); + flatMap(Collection::stream). + collect(Collectors.toList()); if (!loadingExceptions.isEmpty()) { LOGGER.fatal(CORE, "Failed to initialize mod containers"); throw new LoadingFailedException(loadingExceptions); } - modList.setLoadedMods(modContainerStream.collect(Collectors.toList())); + modList.setLoadedMods(modContainers); dispatchAndHandleError(LifecycleEventProvider.CONSTRUCT); GameData.fireCreateRegistryEvents(LifecycleEventProvider.CREATE_REGISTRIES, this::dispatchAndHandleError); ObjectHolderRegistry.findObjectHolders();