Search in sources :

Example 1 with PackMetadataSection

use of net.minecraft.client.resources.data.PackMetadataSection 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)

Aggregations

IOException (java.io.IOException)1 IResourcePack (net.minecraft.client.resources.IResourcePack)1 LegacyV2Adapter (net.minecraft.client.resources.LegacyV2Adapter)1 PackMetadataSection (net.minecraft.client.resources.data.PackMetadataSection)1 DuplicateModsFoundException (net.minecraftforge.fml.common.DuplicateModsFoundException)1 Java8VersionException (net.minecraftforge.fml.common.Java8VersionException)1 LoaderException (net.minecraftforge.fml.common.LoaderException)1 MissingModsException (net.minecraftforge.fml.common.MissingModsException)1 WrongMinecraftVersionException (net.minecraftforge.fml.common.WrongMinecraftVersionException)1 ModSortingException (net.minecraftforge.fml.common.toposort.ModSortingException)1