Search in sources :

Example 1 with IResourcePack

use of net.minecraft.resources.IResourcePack in project Magma-1.16.x by magmafoundation.

the class ClientHooks method logMissingTextureErrors.

public static void logMissingTextureErrors() {
    if (missingTextures.isEmpty() && brokenTextures.isEmpty()) {
        return;
    }
    Logger logger = LogManager.getLogger("FML.TEXTURE_ERRORS");
    logger.error(Strings.repeat("+=", 25));
    logger.error("The following texture errors were found.");
    Map<String, FallbackResourceManager> resManagers = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, (SimpleReloadableResourceManager) Minecraft.getInstance().getResourceManager(), "field_199014" + "_c");
    for (String resourceDomain : badTextureDomains) {
        Set<ResourceLocation> missing = missingTextures.get(resourceDomain);
        logger.error(Strings.repeat("=", 50));
        logger.error("  DOMAIN {}", resourceDomain);
        logger.error(Strings.repeat("-", 50));
        logger.error("  domain {} is missing {} texture{}", resourceDomain, missing.size(), missing.size() != 1 ? "s" : "");
        FallbackResourceManager fallbackResourceManager = resManagers.get(resourceDomain);
        if (fallbackResourceManager == null) {
            logger.error("    domain {} is missing a resource manager - it is probably a side-effect of automatic texture processing", resourceDomain);
        } else {
            List<IResourcePack> resPacks = fallbackResourceManager.fallbacks;
            logger.error("    domain {} has {} location{}:", resourceDomain, resPacks.size(), resPacks.size() != 1 ? "s" : "");
            for (IResourcePack resPack : resPacks) {
                if (resPack instanceof ModFileResourcePack) {
                    ModFileResourcePack modRP = (ModFileResourcePack) resPack;
                    List<IModInfo> mods = modRP.getModFile().getModInfos();
                    logger.error("      mod(s) {} resources at {}", mods.stream().map(IModInfo::getDisplayName).collect(Collectors.toList()), modRP.getModFile().getFilePath());
                } else if (resPack instanceof ResourcePack) {
                    logger.error("      resource pack at path {}", ((ResourcePack) resPack).file.getPath());
                } else {
                    logger.error("      unknown resourcepack type {} : {}", resPack.getClass().getName(), resPack.getName());
                }
            }
        }
        logger.error(Strings.repeat("-", 25));
        if (missingTextures.containsKey(resourceDomain)) {
            logger.error("    The missing resources for domain {} are:", resourceDomain);
            for (ResourceLocation rl : missing) {
                logger.error("      {}", rl.getPath());
            }
            logger.error(Strings.repeat("-", 25));
        }
        if (!brokenTextures.containsRow(resourceDomain)) {
            logger.error("    No other errors exist for domain {}", resourceDomain);
        } else {
            logger.error("    The following other errors were reported for domain {}:", resourceDomain);
            Map<String, Set<ResourceLocation>> resourceErrs = brokenTextures.row(resourceDomain);
            for (String error : resourceErrs.keySet()) {
                logger.error(Strings.repeat("-", 25));
                logger.error("    Problem: {}", error);
                for (ResourceLocation rl : resourceErrs.get(error)) {
                    logger.error("      {}", rl.getPath());
                }
            }
        }
        logger.error(Strings.repeat("=", 50));
    }
    logger.error(Strings.repeat("+=", 25));
}
Also used : IModInfo(net.minecraftforge.forgespi.language.IModInfo) ResourcePack(net.minecraft.resources.ResourcePack) IResourcePack(net.minecraft.resources.IResourcePack) ModFileResourcePack(net.minecraftforge.fml.packs.ModFileResourcePack) Logger(org.apache.logging.log4j.Logger) IResourcePack(net.minecraft.resources.IResourcePack) ResourceLocation(net.minecraft.util.ResourceLocation) ModFileResourcePack(net.minecraftforge.fml.packs.ModFileResourcePack) FallbackResourceManager(net.minecraft.resources.FallbackResourceManager)

Example 2 with IResourcePack

use of net.minecraft.resources.IResourcePack in project LoliServer by Loli-Server.

the class DelegatingResourcePack method buildNamespaceMap.

private Map<String, List<IResourcePack>> buildNamespaceMap(ResourcePackType type, List<IResourcePack> packList) {
    Map<String, List<IResourcePack>> map = new HashMap<>();
    for (IResourcePack pack : packList) {
        for (String namespace : pack.getNamespaces(type)) {
            map.computeIfAbsent(namespace, k -> new ArrayList<>()).add(pack);
        }
    }
    map.replaceAll((k, list) -> ImmutableList.copyOf(list));
    return ImmutableMap.copyOf(map);
}
Also used : IMetadataSectionSerializer(net.minecraft.resources.data.IMetadataSectionSerializer) java.util(java.util) ResourcePackFileNotFoundException(net.minecraft.resources.ResourcePackFileNotFoundException) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) IOException(java.io.IOException) ResourcePack(net.minecraft.resources.ResourcePack) Collectors(java.util.stream.Collectors) File(java.io.File) ImmutableList(com.google.common.collect.ImmutableList) ResourcePackType(net.minecraft.resources.ResourcePackType) ResourceLocation(net.minecraft.util.ResourceLocation) IResourcePack(net.minecraft.resources.IResourcePack) InputStream(java.io.InputStream) PackMetadataSection(net.minecraft.resources.data.PackMetadataSection) ImmutableList(com.google.common.collect.ImmutableList) IResourcePack(net.minecraft.resources.IResourcePack)

Example 3 with IResourcePack

use of net.minecraft.resources.IResourcePack in project Magma-1.16.x by magmafoundation.

the class DelegatingResourcePack method buildNamespaceMap.

private Map<String, List<IResourcePack>> buildNamespaceMap(ResourcePackType type, List<IResourcePack> packList) {
    Map<String, List<IResourcePack>> map = new HashMap<>();
    for (IResourcePack pack : packList) {
        for (String namespace : pack.getNamespaces(type)) {
            map.computeIfAbsent(namespace, k -> new ArrayList<>()).add(pack);
        }
    }
    map.replaceAll((k, list) -> ImmutableList.copyOf(list));
    return ImmutableMap.copyOf(map);
}
Also used : IMetadataSectionSerializer(net.minecraft.resources.data.IMetadataSectionSerializer) java.util(java.util) ResourcePackFileNotFoundException(net.minecraft.resources.ResourcePackFileNotFoundException) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) IOException(java.io.IOException) ResourcePack(net.minecraft.resources.ResourcePack) Collectors(java.util.stream.Collectors) File(java.io.File) ImmutableList(com.google.common.collect.ImmutableList) ResourcePackType(net.minecraft.resources.ResourcePackType) ResourceLocation(net.minecraft.util.ResourceLocation) IResourcePack(net.minecraft.resources.IResourcePack) InputStream(java.io.InputStream) PackMetadataSection(net.minecraft.resources.data.PackMetadataSection) ImmutableList(com.google.common.collect.ImmutableList) IResourcePack(net.minecraft.resources.IResourcePack)

Example 4 with IResourcePack

use of net.minecraft.resources.IResourcePack in project LoliServer by Loli-Server.

the class ClientHooks method logMissingTextureErrors.

public static void logMissingTextureErrors() {
    if (missingTextures.isEmpty() && brokenTextures.isEmpty()) {
        return;
    }
    Logger logger = LogManager.getLogger("FML.TEXTURE_ERRORS");
    logger.error(Strings.repeat("+=", 25));
    logger.error("The following texture errors were found.");
    Map<String, FallbackResourceManager> resManagers = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, (SimpleReloadableResourceManager) Minecraft.getInstance().getResourceManager(), "field_199014" + "_c");
    for (String resourceDomain : badTextureDomains) {
        Set<ResourceLocation> missing = missingTextures.get(resourceDomain);
        logger.error(Strings.repeat("=", 50));
        logger.error("  DOMAIN {}", resourceDomain);
        logger.error(Strings.repeat("-", 50));
        logger.error("  domain {} is missing {} texture{}", resourceDomain, missing.size(), missing.size() != 1 ? "s" : "");
        FallbackResourceManager fallbackResourceManager = resManagers.get(resourceDomain);
        if (fallbackResourceManager == null) {
            logger.error("    domain {} is missing a resource manager - it is probably a side-effect of automatic texture processing", resourceDomain);
        } else {
            List<IResourcePack> resPacks = fallbackResourceManager.fallbacks;
            logger.error("    domain {} has {} location{}:", resourceDomain, resPacks.size(), resPacks.size() != 1 ? "s" : "");
            for (IResourcePack resPack : resPacks) {
                if (resPack instanceof ModFileResourcePack) {
                    ModFileResourcePack modRP = (ModFileResourcePack) resPack;
                    List<IModInfo> mods = modRP.getModFile().getModInfos();
                    logger.error("      mod(s) {} resources at {}", mods.stream().map(IModInfo::getDisplayName).collect(Collectors.toList()), modRP.getModFile().getFilePath());
                } else if (resPack instanceof ResourcePack) {
                    logger.error("      resource pack at path {}", ((ResourcePack) resPack).file.getPath());
                } else {
                    logger.error("      unknown resourcepack type {} : {}", resPack.getClass().getName(), resPack.getName());
                }
            }
        }
        logger.error(Strings.repeat("-", 25));
        if (missingTextures.containsKey(resourceDomain)) {
            logger.error("    The missing resources for domain {} are:", resourceDomain);
            for (ResourceLocation rl : missing) {
                logger.error("      {}", rl.getPath());
            }
            logger.error(Strings.repeat("-", 25));
        }
        if (!brokenTextures.containsRow(resourceDomain)) {
            logger.error("    No other errors exist for domain {}", resourceDomain);
        } else {
            logger.error("    The following other errors were reported for domain {}:", resourceDomain);
            Map<String, Set<ResourceLocation>> resourceErrs = brokenTextures.row(resourceDomain);
            for (String error : resourceErrs.keySet()) {
                logger.error(Strings.repeat("-", 25));
                logger.error("    Problem: {}", error);
                for (ResourceLocation rl : resourceErrs.get(error)) {
                    logger.error("      {}", rl.getPath());
                }
            }
        }
        logger.error(Strings.repeat("=", 50));
    }
    logger.error(Strings.repeat("+=", 25));
}
Also used : IModInfo(net.minecraftforge.forgespi.language.IModInfo) ResourcePack(net.minecraft.resources.ResourcePack) IResourcePack(net.minecraft.resources.IResourcePack) ModFileResourcePack(net.minecraftforge.fml.packs.ModFileResourcePack) Logger(org.apache.logging.log4j.Logger) IResourcePack(net.minecraft.resources.IResourcePack) ResourceLocation(net.minecraft.util.ResourceLocation) ModFileResourcePack(net.minecraftforge.fml.packs.ModFileResourcePack) FallbackResourceManager(net.minecraft.resources.FallbackResourceManager)

Aggregations

IResourcePack (net.minecraft.resources.IResourcePack)4 ResourcePack (net.minecraft.resources.ResourcePack)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 java.util (java.util)2 Predicate (java.util.function.Predicate)2 Collectors (java.util.stream.Collectors)2 FallbackResourceManager (net.minecraft.resources.FallbackResourceManager)2 ResourcePackFileNotFoundException (net.minecraft.resources.ResourcePackFileNotFoundException)2 ResourcePackType (net.minecraft.resources.ResourcePackType)2 IMetadataSectionSerializer (net.minecraft.resources.data.IMetadataSectionSerializer)2 PackMetadataSection (net.minecraft.resources.data.PackMetadataSection)2 ModFileResourcePack (net.minecraftforge.fml.packs.ModFileResourcePack)2 IModInfo (net.minecraftforge.forgespi.language.IModInfo)2 Logger (org.apache.logging.log4j.Logger)2