Search in sources :

Example 1 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project MinecraftForge by MinecraftForge.

the class FMLClientHandler method logMissingTextureErrors.

public void logMissingTextureErrors() {
    if (missingTextures.isEmpty() && brokenTextures.isEmpty()) {
        return;
    }
    Logger logger = LogManager.getLogger("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.getMinecraft().getResourceManager(), "domainResourceManagers", "field_110548" + "_a");
    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 = ObfuscationReflectionHelper.getPrivateValue(FallbackResourceManager.class, fallbackResourceManager, "resourcePacks", "field_110540" + "_a");
            logger.error("    domain {} has {} location{}:", resourceDomain, resPacks.size(), resPacks.size() != 1 ? "s" : "");
            for (IResourcePack resPack : resPacks) {
                if (resPack instanceof FMLContainerHolder) {
                    FMLContainerHolder containerHolder = (FMLContainerHolder) resPack;
                    ModContainer fmlContainer = containerHolder.getFMLContainer();
                    logger.error("      mod {} resources at {}", fmlContainer.getModId(), fmlContainer.getSource().getPath());
                } else if (resPack instanceof AbstractResourcePack) {
                    AbstractResourcePack resourcePack = (AbstractResourcePack) resPack;
                    File resPath = ObfuscationReflectionHelper.getPrivateValue(AbstractResourcePack.class, resourcePack, "resourcePackFile", "field_110597" + "_b");
                    logger.error("      resource pack at path {}", resPath.getPath());
                } else {
                    logger.error("      unknown resourcepack type {} : {}", resPack.getClass().getName(), resPack.getPackName());
                }
            }
        }
        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.getResourcePath());
            }
            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.getResourcePath());
                }
            }
        }
        logger.error(Strings.repeat("=", 50));
    }
    logger.error(Strings.repeat("+=", 25));
}
Also used : Set(java.util.Set) ForgeModContainer(net.minecraftforge.common.ForgeModContainer) ModContainer(net.minecraftforge.fml.common.ModContainer) DummyModContainer(net.minecraftforge.fml.common.DummyModContainer) AbstractResourcePack(net.minecraft.client.resources.AbstractResourcePack) Logger(org.apache.logging.log4j.Logger) FMLContainerHolder(net.minecraftforge.fml.common.FMLContainerHolder) IResourcePack(net.minecraft.client.resources.IResourcePack) ResourceLocation(net.minecraft.util.ResourceLocation) FallbackResourceManager(net.minecraft.client.resources.FallbackResourceManager) File(java.io.File)

Example 2 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project BetterRain by OreCruncher.

the class Footsteps method reloadAcoustics.

private void reloadAcoustics(final List<IResourcePack> repo) {
    AcousticsManager acoustics = new AcousticsManager(this.isolator);
    Scanner scanner = null;
    InputStream stream = null;
    for (final IResourcePack pack : repo) {
        try {
            stream = this.dealer.openAcoustics(pack);
            if (stream != null) {
                scanner = new Scanner(stream);
                final String jasonString = scanner.useDelimiter("\\Z").next();
                new AcousticsJsonReader("").parseJSON(jasonString, acoustics);
            }
        } catch (final IOException e) {
            ModLog.debug("Unable to load acoustic data from pack %s", pack.getPackName());
        } finally {
            try {
                if (scanner != null)
                    scanner.close();
                if (stream != null)
                    stream.close();
            } catch (final IOException e) {
                ;
            }
        }
    }
    this.isolator.setAcoustics(acoustics);
    this.isolator.setSoundPlayer(new UserConfigSoundPlayerWrapper(acoustics));
    this.isolator.setDefaultStepPlayer(acoustics);
}
Also used : AcousticsManager(org.blockartistry.mod.DynSurround.client.footsteps.mcpackage.implem.AcousticsManager) Scanner(java.util.Scanner) UserConfigSoundPlayerWrapper(org.blockartistry.mod.DynSurround.client.footsteps.game.system.UserConfigSoundPlayerWrapper) AcousticsJsonReader(org.blockartistry.mod.DynSurround.client.footsteps.parsers.AcousticsJsonReader) InputStream(java.io.InputStream) IOException(java.io.IOException) IResourcePack(net.minecraft.client.resources.IResourcePack)

Example 3 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project BetterRain by OreCruncher.

the class Footsteps method reloadEverything.

public void reloadEverything() {
    this.isolator = new PFIsolator();
    final List<IResourcePack> repo = this.dealer.findResourcePacks();
    reloadBlockMap(repo);
    reloadPrimitiveMap(repo);
    reloadAcoustics(repo);
    this.isolator.setSolver(new PFSolver(this.isolator));
    reloadVariator(repo);
    this.isolator.setGenerator(new PFReaderH(this.isolator));
/*
		 * this.isolator.setGenerator(getConfig().getInteger("custom.stance") ==
		 * 0 ? new PFReaderH(this.isolator) : new PFReaderQP(this.isolator));
		 */
}
Also used : PFIsolator(org.blockartistry.mod.DynSurround.client.footsteps.game.system.PFIsolator) PFSolver(org.blockartistry.mod.DynSurround.client.footsteps.game.system.PFSolver) PFReaderH(org.blockartistry.mod.DynSurround.client.footsteps.game.system.PFReaderH) IResourcePack(net.minecraft.client.resources.IResourcePack)

Example 4 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project MinecraftForge by MinecraftForge.

the class FMLClientHandler method addModAsResource.

@Override
public void addModAsResource(ModContainer container) {
    Class<?> resourcePackType = container.getCustomResourcePackClass();
    if (resourcePackType != null) {
        try {
            IResourcePack pack = (IResourcePack) resourcePackType.getConstructor(ModContainer.class).newInstance(container);
            PackMetadataSection meta = (PackMetadataSection) pack.getPackMetadata(this.metaSerializer, "pack");
            if (meta != null && meta.getPackFormat() == 2) {
                pack = new LegacyV2Adapter(pack);
            }
            resourcePackList.add(pack);
            resourcePackMap.put(container.getModId(), pack);
        } catch (NoSuchMethodException e) {
            FMLLog.log(Level.ERROR, "The container %s (type %s) returned an invalid class for it's resource pack.", container.getName(), container.getClass().getName());
            return;
        } catch (Exception e) {
            FMLLog.log(Level.ERROR, e, "An unexpected exception occurred constructing the custom resource pack for %s", container.getName());
            throw Throwables.propagate(e);
        }
    }
}
Also used : LegacyV2Adapter(net.minecraft.client.resources.LegacyV2Adapter) IResourcePack(net.minecraft.client.resources.IResourcePack) WrongMinecraftVersionException(net.minecraftforge.fml.common.WrongMinecraftVersionException) DuplicateModsFoundException(net.minecraftforge.fml.common.DuplicateModsFoundException) LoaderException(net.minecraftforge.fml.common.LoaderException) IOException(java.io.IOException) ModSortingException(net.minecraftforge.fml.common.toposort.ModSortingException) MissingModsException(net.minecraftforge.fml.common.MissingModsException) Java8VersionException(net.minecraftforge.fml.common.Java8VersionException) PackMetadataSection(net.minecraft.client.resources.data.PackMetadataSection)

Example 5 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project MinecraftForge by MinecraftForge.

the class GuiModList method updateCache.

private void updateCache() {
    configModButton.visible = false;
    disableModButton.visible = false;
    modInfo = null;
    if (selectedMod == null)
        return;
    ResourceLocation logoPath = null;
    Dimension logoDims = new Dimension(0, 0);
    List<String> lines = new ArrayList<String>();
    CheckResult vercheck = ForgeVersion.getResult(selectedMod);
    String logoFile = selectedMod.getMetadata().logoFile;
    if (!logoFile.isEmpty()) {
        TextureManager tm = mc.getTextureManager();
        IResourcePack pack = FMLClientHandler.instance().getResourcePackFor(selectedMod.getModId());
        try {
            BufferedImage logo = null;
            if (pack != null) {
                logo = pack.getPackImage();
            } else {
                InputStream logoResource = getClass().getResourceAsStream(logoFile);
                if (logoResource != null)
                    logo = ImageIO.read(logoResource);
            }
            if (logo != null) {
                logoPath = tm.getDynamicTextureLocation("modlogo", new DynamicTexture(logo));
                logoDims = new Dimension(logo.getWidth(), logo.getHeight());
            }
        } catch (IOException e) {
        }
    }
    if (!selectedMod.getMetadata().autogenerated) {
        disableModButton.visible = true;
        disableModButton.enabled = true;
        disableModButton.packedFGColour = 0;
        Disableable disableable = selectedMod.canBeDisabled();
        if (disableable == Disableable.RESTART) {
            disableModButton.packedFGColour = 0xFF3377;
        } else if (disableable != Disableable.YES) {
            disableModButton.enabled = false;
        }
        IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(selectedMod);
        configModButton.visible = true;
        configModButton.enabled = guiFactory != null && guiFactory.mainConfigGuiClass() != null;
        lines.add(selectedMod.getMetadata().name);
        lines.add(String.format("Version: %s (%s)", selectedMod.getDisplayVersion(), selectedMod.getVersion()));
        lines.add(String.format("Mod ID: '%s' Mod State: %s", selectedMod.getModId(), Loader.instance().getModState(selectedMod)));
        if (!selectedMod.getMetadata().credits.isEmpty()) {
            lines.add("Credits: " + selectedMod.getMetadata().credits);
        }
        lines.add("Authors: " + selectedMod.getMetadata().getAuthorList());
        lines.add("URL: " + selectedMod.getMetadata().url);
        if (selectedMod.getMetadata().childMods.isEmpty())
            lines.add("No child mods for this mod");
        else
            lines.add("Child mods: " + selectedMod.getMetadata().getChildModList());
        if (vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED)
            lines.add("Update Available: " + (vercheck.url == null ? "" : vercheck.url));
        lines.add(null);
        lines.add(selectedMod.getMetadata().description);
    } else {
        lines.add(WHITE + selectedMod.getName());
        lines.add(WHITE + "Version: " + selectedMod.getVersion());
        lines.add(WHITE + "Mod State: " + Loader.instance().getModState(selectedMod));
        if (vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED)
            lines.add("Update Available: " + (vercheck.url == null ? "" : vercheck.url));
        lines.add(null);
        lines.add(RED + "No mod information found");
        lines.add(RED + "Ask your mod author to provide a mod mcmod.info file");
    }
    if ((vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED) && vercheck.changes.size() > 0) {
        lines.add(null);
        lines.add("Changes:");
        for (Entry<ComparableVersion, String> entry : vercheck.changes.entrySet()) {
            lines.add("  " + entry.getKey() + ":");
            lines.add(entry.getValue());
            lines.add(null);
        }
    }
    modInfo = new Info(this.width - this.listWidth - 30, lines, logoPath, logoDims);
}
Also used : InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) DynamicTexture(net.minecraft.client.renderer.texture.DynamicTexture) Dimension(java.awt.Dimension) TextComponentString(net.minecraft.util.text.TextComponentString) IOException(java.io.IOException) ComparableVersion(net.minecraftforge.fml.common.versioning.ComparableVersion) IResourcePack(net.minecraft.client.resources.IResourcePack) BufferedImage(java.awt.image.BufferedImage) TextureManager(net.minecraft.client.renderer.texture.TextureManager) ResourceLocation(net.minecraft.util.ResourceLocation) CheckResult(net.minecraftforge.common.ForgeVersion.CheckResult) Disableable(net.minecraftforge.fml.common.ModContainer.Disableable)

Aggregations

IResourcePack (net.minecraft.client.resources.IResourcePack)11 IOException (java.io.IOException)7 InputStream (java.io.InputStream)5 File (java.io.File)2 ArrayList (java.util.ArrayList)2 LegacyV2Adapter (net.minecraft.client.resources.LegacyV2Adapter)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ModContainer (net.minecraftforge.fml.common.ModContainer)2 ForgeRedirectedResourcePack (biomesoplenty.client.texture.ForgeRedirectedResourcePack)1 ImagesPack (com.chattriggers.ctjs.utils.ImagesPack)1 Dimension (java.awt.Dimension)1 BufferedImage (java.awt.image.BufferedImage)1 FileNotFoundException (java.io.FileNotFoundException)1 Field (java.lang.reflect.Field)1 List (java.util.List)1 Scanner (java.util.Scanner)1 Set (java.util.Set)1 DynamicTexture (net.minecraft.client.renderer.texture.DynamicTexture)1 TextureManager (net.minecraft.client.renderer.texture.TextureManager)1 AbstractResourcePack (net.minecraft.client.resources.AbstractResourcePack)1