Search in sources :

Example 1 with DelegatingResourcePack

use of net.minecraftforge.resource.DelegatingResourcePack in project MinecraftForge by MinecraftForge.

the class ClientModLoader method clientPackFinder.

private static void clientPackFinder(Map<IModFile, ? extends PathResourcePack> modResourcePacks, Consumer<Pack> consumer, Pack.PackConstructor factory) {
    List<PathResourcePack> hiddenPacks = new ArrayList<>();
    for (Entry<IModFile, ? extends PathResourcePack> e : modResourcePacks.entrySet()) {
        IModInfo mod = e.getKey().getModInfos().get(0);
        final String name = "mod:" + mod.getModId();
        final Pack packInfo = Pack.create(name, false, e::getValue, factory, Pack.Position.BOTTOM, PackSource.DEFAULT);
        if (packInfo == null) {
            // Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong
            ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey()));
            continue;
        }
        LOGGER.debug(CORE, "Generating PackInfo named {} for mod file {}", name, e.getKey().getFilePath());
        if (mod.getOwningFile().showAsResourcePack()) {
            consumer.accept(packInfo);
        } else {
            hiddenPacks.add(e.getValue());
        }
    }
    final Pack packInfo = Pack.create("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources", new PackMetadataSection(new TranslatableComponent("fml.resources.modresources", hiddenPacks.size()), PackType.CLIENT_RESOURCES.getVersion(SharedConstants.getCurrentVersion())), hiddenPacks), factory, Pack.Position.BOTTOM, PackSource.DEFAULT);
    consumer.accept(packInfo);
}
Also used : DelegatingResourcePack(net.minecraftforge.resource.DelegatingResourcePack) IModInfo(net.minecraftforge.forgespi.language.IModInfo) ClientPackSource(net.minecraft.client.resources.ClientPackSource) RepositorySource(net.minecraft.server.packs.repository.RepositorySource) PackType(net.minecraft.server.packs.PackType) File(java.io.File) MinecraftForge(net.minecraftforge.common.MinecraftForge) PackSource(net.minecraft.server.packs.repository.PackSource) IModFile(net.minecraftforge.forgespi.locating.IModFile) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) IModFile(net.minecraftforge.forgespi.locating.IModFile) Pack(net.minecraft.server.packs.repository.Pack) PathResourcePack(net.minecraftforge.resource.PathResourcePack) DelegatingResourcePack(net.minecraftforge.resource.DelegatingResourcePack) PathResourcePack(net.minecraftforge.resource.PathResourcePack) PackMetadataSection(net.minecraft.server.packs.metadata.pack.PackMetadataSection)

Aggregations

File (java.io.File)1 ClientPackSource (net.minecraft.client.resources.ClientPackSource)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 PackType (net.minecraft.server.packs.PackType)1 PackMetadataSection (net.minecraft.server.packs.metadata.pack.PackMetadataSection)1 Pack (net.minecraft.server.packs.repository.Pack)1 PackSource (net.minecraft.server.packs.repository.PackSource)1 RepositorySource (net.minecraft.server.packs.repository.RepositorySource)1 MinecraftForge (net.minecraftforge.common.MinecraftForge)1 IModInfo (net.minecraftforge.forgespi.language.IModInfo)1 IModFile (net.minecraftforge.forgespi.locating.IModFile)1 DelegatingResourcePack (net.minecraftforge.resource.DelegatingResourcePack)1 PathResourcePack (net.minecraftforge.resource.PathResourcePack)1