Search in sources :

Example 31 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project CumServerPro by MCUmbrella.

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.error("The container {} (type {}) returned an invalid class for its resource pack.", container.getName(), container.getClass().getName());
        } catch (Exception e) {
            FormattedMessage message = new FormattedMessage("An unexpected exception occurred constructing the custom resource pack for {} ({})", container.getName(), container.getModId());
            throw new RuntimeException(message.getFormattedMessage(), 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) PackMetadataSection(net.minecraft.client.resources.data.PackMetadataSection) FormattedMessage(org.apache.logging.log4j.message.FormattedMessage)

Example 32 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project WizClient-1.8.9-Version by WizClient.

the class CustomItems method update.

public static void update() {
    itemProperties = (CustomItemProperties[][]) null;
    enchantmentProperties = (CustomItemProperties[][]) null;
    useGlint = true;
    if (Config.isCustomItems()) {
        readCitProperties("mcpatcher/cit.properties");
        IResourcePack[] airesourcepack = Config.getResourcePacks();
        for (int i = airesourcepack.length - 1; i >= 0; --i) {
            IResourcePack iresourcepack = airesourcepack[i];
            update(iresourcepack);
        }
        update(Config.getDefaultResourcePack());
        if (itemProperties.length <= 0) {
            itemProperties = (CustomItemProperties[][]) null;
        }
        if (enchantmentProperties.length <= 0) {
            enchantmentProperties = (CustomItemProperties[][]) null;
        }
    }
}
Also used : IResourcePack(net.minecraft.client.resources.IResourcePack)

Example 33 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project WizClient-1.8.9-Version by WizClient.

the class Config method getDefiningResourcePack.

public static IResourcePack getDefiningResourcePack(ResourceLocation p_getDefiningResourcePack_0_) {
    ResourcePackRepository resourcepackrepository = minecraft.getResourcePackRepository();
    IResourcePack iresourcepack = resourcepackrepository.getResourcePackInstance();
    if (iresourcepack != null && iresourcepack.resourceExists(p_getDefiningResourcePack_0_)) {
        return iresourcepack;
    } else {
        List<ResourcePackRepository.Entry> list = resourcepackrepository.repositoryEntries;
        for (int i = list.size() - 1; i >= 0; --i) {
            ResourcePackRepository.Entry resourcepackrepository$entry = (ResourcePackRepository.Entry) list.get(i);
            IResourcePack iresourcepack1 = resourcepackrepository$entry.getResourcePack();
            if (iresourcepack1.resourceExists(p_getDefiningResourcePack_0_)) {
                return iresourcepack1;
            }
        }
        if (getDefaultResourcePack().resourceExists(p_getDefiningResourcePack_0_)) {
            return getDefaultResourcePack();
        } else {
            return null;
        }
    }
}
Also used : ResourcePackRepository(net.minecraft.client.resources.ResourcePackRepository) IResourcePack(net.minecraft.client.resources.IResourcePack)

Example 34 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 35 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)36 IOException (java.io.IOException)13 File (java.io.File)12 InputStream (java.io.InputStream)10 List (java.util.List)10 ArrayList (java.util.ArrayList)8 ResourceLocation (net.minecraft.util.ResourceLocation)7 ResourcePackRepository (net.minecraft.client.resources.ResourcePackRepository)6 Field (java.lang.reflect.Field)5 AbstractResourcePack (net.minecraft.client.resources.AbstractResourcePack)4 IResourceManager (net.minecraft.client.resources.IResourceManager)4 LegacyV2Adapter (net.minecraft.client.resources.LegacyV2Adapter)4 FileNotFoundException (java.io.FileNotFoundException)3 Set (java.util.Set)3 FallbackResourceManager (net.minecraft.client.resources.FallbackResourceManager)3 FMLClientHandler (net.minecraftforge.fml.client.FMLClientHandler)3 Dimension (java.awt.Dimension)2 BufferedImage (java.awt.image.BufferedImage)2 FileInputStream (java.io.FileInputStream)2 Map (java.util.Map)2