Use the resource pack directly in the GuiModList, skip the resourcepackinfo.
Closes #5418 Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
parent
36866fed10
commit
e4d20a80ed
2 changed files with 18 additions and 24 deletions
|
@ -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<ResourceLocation, Dimension> 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)
|
||||
|
|
|
@ -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<ModFile, ModFileResourcePack> modResourcePacks;
|
||||
private static ResourcePackList<?> resourcePackList;
|
||||
|
||||
public static ModFileResourcePack getResourcePackFor(String modId)
|
||||
public static Optional<ModFileResourcePack> getResourcePackFor(String modId)
|
||||
{
|
||||
return modResourcePacks.get(ModList.get().getModFileById(modId).getFile());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends ResourcePackInfo> 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 <T extends ResourcePackInfo> void loadResourcePacks(ResourcePackList<T> resourcePacks) {
|
||||
|
|
Loading…
Reference in a new issue