Search in sources :

Example 16 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)

Example 17 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project ct.js by ChatTriggers.

the class CTJS method injectResourcePack.

private void injectResourcePack(String path) {
    try {
        File pictures = new File(path, "ChatTriggers/images/");
        Field field = FMLClientHandler.class.getDeclaredField("resourcePackList");
        field.setAccessible(true);
        List<IResourcePack> packs = (List<IResourcePack>) field.get(FMLClientHandler.instance());
        imagesPack = new ImagesPack(pictures);
        packs.add(imagesPack);
        pictures.mkdirs();
        assetsDir = pictures;
    } catch (Exception exception) {
        exception.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) List(java.util.List) File(java.io.File) IResourcePack(net.minecraft.client.resources.IResourcePack) ImagesPack(com.chattriggers.ctjs.utils.ImagesPack) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 18 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project BiomesOPlenty by Glitchfiend.

the class ClientProxy method replaceForgeResources.

private static void replaceForgeResources() {
    if (MiscConfigurationHandler.overrideForgeBuckets) {
        FMLClientHandler clientHandler = FMLClientHandler.instance();
        List<IResourcePack> resourcePackList = ReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackList");
        Map<String, IResourcePack> resourcePackMap = ReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackMap");
        LegacyV2Adapter resourcePack = (LegacyV2Adapter) clientHandler.getResourcePackFor("forge");
        // Remove the old resource pack from the registry
        resourcePackList.remove(resourcePack);
        resourcePackMap.remove("forge");
        // Replace Forge's resource pack with our modified version
        ForgeRedirectedResourcePack redirectedResourcePack = new ForgeRedirectedResourcePack(FMLCommonHandler.instance().findContainerFor("forge"));
        // Add our new resource pack in its place
        resourcePackList.add(redirectedResourcePack);
        resourcePackMap.put("forge", redirectedResourcePack);
    }
}
Also used : ForgeRedirectedResourcePack(biomesoplenty.client.texture.ForgeRedirectedResourcePack) FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) LegacyV2Adapter(net.minecraft.client.resources.LegacyV2Adapter) IResourcePack(net.minecraft.client.resources.IResourcePack)

Example 19 with IResourcePack

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

the class PFResourcePackDealer method findResourcePacks.

public List<IResourcePack> findResourcePacks() {
    final List<ResourcePackRepository.Entry> repo = Minecraft.getMinecraft().getResourcePackRepository().getRepositoryEntries();
    final List<IResourcePack> foundEntries = new ArrayList<IResourcePack>();
    foundEntries.add(new DefaultPack());
    // a config file embedded.
    for (final ModContainer mod : Loader.instance().getActiveModList()) foundEntries.add(new DefaultPack(mod.getModId()));
    for (final ResourcePackRepository.Entry pack : repo) {
        ModLog.debug("Resource Pack: %s", pack.getResourcePackName());
        if (checkCompatible(pack)) {
            ModLog.debug("Found Footsteps resource pack: %s", pack.getResourcePackName());
            foundEntries.add(pack.getResourcePack());
        }
    }
    return foundEntries;
}
Also used : ModContainer(net.minecraftforge.fml.common.ModContainer) ResourcePackRepository(net.minecraft.client.resources.ResourcePackRepository) ArrayList(java.util.ArrayList) IResourcePack(net.minecraft.client.resources.IResourcePack)

Example 20 with IResourcePack

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

the class Footsteps method reloadBlockMap.

private void reloadBlockMap(final List<IResourcePack> repo) {
    final IBlockMap blockMap = new LegacyCapableBlockMap();
    ForgeDictionary.initialize(blockMap);
    for (final IResourcePack pack : repo) {
        InputStream stream = null;
        try {
            stream = this.dealer.openBlockMap(pack);
            if (stream != null)
                Register.setup(ConfigProperty.fromStream(stream), blockMap);
        } catch (final IOException e) {
            ModLog.debug("Unable to load block map data from pack %s", pack.getPackName());
        } finally {
            if (stream != null)
                try {
                    stream.close();
                } catch (final IOException e) {
                    ;
                }
        }
    }
    this.isolator.setBlockMap(blockMap);
}
Also used : LegacyCapableBlockMap(org.blockartistry.mod.DynSurround.client.footsteps.mcpackage.implem.LegacyCapableBlockMap) InputStream(java.io.InputStream) IBlockMap(org.blockartistry.mod.DynSurround.client.footsteps.mcpackage.interfaces.IBlockMap) IOException(java.io.IOException) IResourcePack(net.minecraft.client.resources.IResourcePack)

Aggregations

IResourcePack (net.minecraft.client.resources.IResourcePack)27 IOException (java.io.IOException)13 File (java.io.File)12 InputStream (java.io.InputStream)10 List (java.util.List)6 ResourceLocation (net.minecraft.util.ResourceLocation)6 AbstractResourcePack (net.minecraft.client.resources.AbstractResourcePack)5 Field (java.lang.reflect.Field)4 ArrayList (java.util.ArrayList)4 LegacyV2Adapter (net.minecraft.client.resources.LegacyV2Adapter)4 FileNotFoundException (java.io.FileNotFoundException)3 ResourcePackRepository (net.minecraft.client.resources.ResourcePackRepository)3 FMLClientHandler (net.minecraftforge.fml.client.FMLClientHandler)3 FileInputStream (java.io.FileInputStream)2 Set (java.util.Set)2 ZipFile (java.util.zip.ZipFile)2 FallbackResourceManager (net.minecraft.client.resources.FallbackResourceManager)2 IResourceManager (net.minecraft.client.resources.IResourceManager)2 PackMetadataSection (net.minecraft.client.resources.data.PackMetadataSection)2 GameSettings (net.minecraft.client.settings.GameSettings)2