diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java index a53070f8a..979cb4d15 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java +++ b/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java @@ -32,13 +32,17 @@ import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.resources.I18n; -import net.minecraft.client.resources.ResourcePackInfoClient; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.fml.*; +import net.minecraftforge.fml.ForgeI18n; +import net.minecraftforge.fml.MavenVersionStringHelper; +import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.VersionChecker; import net.minecraftforge.fml.client.ConfigGuiHandler; +import net.minecraftforge.fml.packs.ModFileResourcePack; import net.minecraftforge.fml.packs.ResourcePackLoader; import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.fml.loading.StringUtils; @@ -433,12 +437,13 @@ public class GuiModList extends GuiScreen Pair logoData = selectedMod.getLogoFile().map(logoFile-> { TextureManager tm = mc.getTextureManager(); - ResourcePackInfoClient pack = ResourcePackLoader.getResourcePackInfoForModId(selectedMod.getModId()); - if (pack == null) pack = ResourcePackLoader.getResourcePackInfoForModId("forge"); + final ModFileResourcePack resourcePack = ResourcePackLoader.getResourcePackFor(selectedMod.getModId()) + .orElse(ResourcePackLoader.getResourcePackFor("forge"). + orElseThrow(()->new RuntimeException("Can't find forge, WHAT!"))); try { NativeImage logo = null; - InputStream logoResource = pack.getResourcePack().getRootResourceStream(logoFile); + InputStream logoResource = resourcePack.getRootResourceStream(logoFile); if (logoResource != null) logo = NativeImage.read(logoResource); if (logo != null) diff --git a/src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java b/src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java index 9250a06de..59f89f9d5 100644 --- a/src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java +++ b/src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java @@ -19,21 +19,18 @@ package net.minecraftforge.fml.packs; -import net.minecraft.resources.*; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.IPackFinder; +import net.minecraft.resources.ResourcePackInfo; +import net.minecraft.resources.ResourcePackList; import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.loading.moddiscovery.ModFile; +import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; import java.util.Map; import java.util.Map.Entry; -import java.util.Objects; +import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; @@ -45,18 +42,10 @@ public class ResourcePackLoader private static Map modResourcePacks; private static ResourcePackList resourcePackList; - public static ModFileResourcePack getResourcePackFor(String modId) + public static Optional getResourcePackFor(String modId) { - return modResourcePacks.get(ModList.get().getModFileById(modId).getFile()); - } - - @SuppressWarnings("unchecked") - public static T getResourcePackInfoForModId(String modId) { - if (Objects.equals(modId, "minecraft")) { - // Additional resources for MC are associated with forge - return getResourcePackFor("forge").getPackInfo(); - } - return getResourcePackFor(modId).getPackInfo(); + return Optional.ofNullable(ModList.get().getModFileById(modId)). + map(ModFileInfo::getFile).map(mf->modResourcePacks.get(mf)); } public static void loadResourcePacks(ResourcePackList resourcePacks) {