Search in sources :

Example 1 with ModLoadingWarning

use of net.minecraftforge.fml.ModLoadingWarning in project MinecraftForge by MinecraftForge.

the class ServerLifecycleHooks method serverPackFinder.

private static void serverPackFinder(Map<IModFile, ? extends PathResourcePack> modResourcePacks, Consumer<Pack> consumer, Pack.PackConstructor factory) {
    for (Entry<IModFile, ? extends PathResourcePack> e : modResourcePacks.entrySet()) {
        IModInfo mod = e.getKey().getModInfos().get(0);
        // skip the minecraft "mod"
        if (Objects.equals(mod.getModId(), "minecraft"))
            continue;
        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());
        consumer.accept(packInfo);
    }
}
Also used : IModInfo(net.minecraftforge.forgespi.language.IModInfo) RepositorySource(net.minecraft.server.packs.repository.RepositorySource) ModLoadingStage(net.minecraftforge.fml.ModLoadingStage) MinecraftForge(net.minecraftforge.common.MinecraftForge) ConnectionType(net.minecraftforge.network.ConnectionType) PackSource(net.minecraft.server.packs.repository.PackSource) IModFile(net.minecraftforge.forgespi.locating.IModFile) LevelResource(net.minecraft.world.level.storage.LevelResource) IModFile(net.minecraftforge.forgespi.locating.IModFile) ModLoadingWarning(net.minecraftforge.fml.ModLoadingWarning) Pack(net.minecraft.server.packs.repository.Pack) PathResourcePack(net.minecraftforge.resource.PathResourcePack)

Aggregations

Pack (net.minecraft.server.packs.repository.Pack)1 PackSource (net.minecraft.server.packs.repository.PackSource)1 RepositorySource (net.minecraft.server.packs.repository.RepositorySource)1 LevelResource (net.minecraft.world.level.storage.LevelResource)1 MinecraftForge (net.minecraftforge.common.MinecraftForge)1 ModLoadingStage (net.minecraftforge.fml.ModLoadingStage)1 ModLoadingWarning (net.minecraftforge.fml.ModLoadingWarning)1 IModInfo (net.minecraftforge.forgespi.language.IModInfo)1 IModFile (net.minecraftforge.forgespi.locating.IModFile)1 ConnectionType (net.minecraftforge.network.ConnectionType)1 PathResourcePack (net.minecraftforge.resource.PathResourcePack)1