Search in sources :

Example 1 with ModMetadata

use of net.fabricmc.loader.api.metadata.ModMetadata in project MasaGadget by plusls.

the class MasaGuiUtil method initMasaModScreenList.

private static void initMasaModScreenList() {
    initialised = true;
    MinecraftClient client = MinecraftClient.getInstance();
    if (!ModInfo.isModLoaded(ModInfo.MODMENU_MOD_ID)) {
        return;
    }
    FabricLoader.getInstance().getEntrypointContainers("modmenu", ModMenuApi.class).forEach(entrypoint -> {
        ModMetadata metadata = entrypoint.getProvider().getMetadata();
        try {
            ModMenuApi api = entrypoint.getEntrypoint();
            Screen screen = api.getModConfigScreenFactory().create(client.currentScreen);
            if (screen instanceof GuiConfigsBase) {
                ConfigScreenFactory<?> configScreenFactory = api.getModConfigScreenFactory();
                masaGuiData.put(configScreenFactory, metadata.getName());
                masaGuiClassData.put(screen.getClass(), configScreenFactory);
            }
        } catch (Throwable e) {
            ModInfo.LOGGER.error("Mod {} provides a broken implementation of ModMenuApi", metadata.getId(), e);
        }
    });
}
Also used : ModMetadata(net.fabricmc.loader.api.metadata.ModMetadata) Screen(net.minecraft.client.gui.screen.Screen) MinecraftClient(net.minecraft.client.MinecraftClient) GuiConfigsBase(fi.dy.masa.malilib.gui.GuiConfigsBase) ModMenuApi(com.terraformersmc.modmenu.api.ModMenuApi)

Example 2 with ModMetadata

use of net.fabricmc.loader.api.metadata.ModMetadata in project StationAPI by ModificationStation.

the class MixinSoundHelper method loadModAudio.

@Environment(EnvType.CLIENT)
private static void loadModAudio(SoundMap array, String channel) {
    try {
        for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) {
            ModMetadata stationMod = modContainer.getMetadata();
            Path basePath = Paths.get("/assets/" + stationMod.getId() + "/stationapi/sounds/" + channel);
            if (MixinSoundHelper.class.getResource(basePath.toString().replace("\\", "/")) != null) {
                RecursiveReader recursiveReader = new RecursiveReader("/assets/" + stationMod.getId() + "/stationapi/sounds/" + channel, (filepath) -> filepath.endsWith(".ogg") || filepath.endsWith(".mp3") || filepath.endsWith(".wav"));
                for (URL audioUrl : recursiveReader.read()) {
                    String audioID = audioUrl.toString().replace("\\", "/").split("/stationapi/sounds/" + channel)[1].replaceFirst("/", "");
                    ((CustomSoundMap) array).putSound(stationMod.getId() + ":" + audioID, audioUrl);
                }
            }
        }
    } catch (IOException | URISyntaxException e) {
        e.printStackTrace();
    }
}
Also used : RecursiveReader(net.modificationstation.stationapi.api.resource.RecursiveReader) ModContainer(net.fabricmc.loader.api.ModContainer) ModMetadata(net.fabricmc.loader.api.metadata.ModMetadata) CustomSoundMap(net.modificationstation.stationapi.api.client.resource.CustomSoundMap) Environment(net.fabricmc.api.Environment)

Example 3 with ModMetadata

use of net.fabricmc.loader.api.metadata.ModMetadata in project StationAPI by ModificationStation.

the class VanillaChecker method init.

@EventListener(priority = ListenerPriority.HIGH)
private static void init(PreInitEvent event) {
    LOGGER.info("Adding vanilla checker lang folder...");
    I18n.addLangFolder(StationAPI.MODID, "/assets/" + MODID + "/lang");
    LOGGER.info("Gathering mods that require client verification...");
    String value = StationAPI.MODID + ":verify_client";
    FabricLoader.getInstance().getAllMods().forEach(modContainer -> {
        ModMetadata modMetadata = modContainer.getMetadata();
        if (modMetadata.containsCustomValue(value) && modMetadata.getCustomValue(value).getAsBoolean())
            CLIENT_REQUIRED_MODS.add(modContainer);
    });
}
Also used : ModMetadata(net.fabricmc.loader.api.metadata.ModMetadata) EventListener(net.mine_diver.unsafeevents.listener.EventListener)

Example 4 with ModMetadata

use of net.fabricmc.loader.api.metadata.ModMetadata in project frame-fabric by moddingplayground.

the class DataMain method main.

public static void main(String[] strings) throws IOException {
    OptionParser opts = new OptionParser();
    OptionSpec<Void> help = opts.accepts("help", "Show the help menu").forHelp();
    OptionSpec<Void> server = opts.accepts("server", "Include server generators");
    OptionSpec<Void> client = opts.accepts("client", "Include client generators");
    OptionSpec<Void> dev = opts.accepts("dev", "Include development tools");
    OptionSpec<Void> reports = opts.accepts("reports", "Include data reports");
    OptionSpec<Void> validate = opts.accepts("validate", "Validate inputs");
    OptionSpec<Void> all = opts.accepts("all", "Include all generators");
    OptionSpec<String> output = opts.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
    OptionSpec<String> extra = opts.accepts("extra", "Additional output folder to copy assets to").withRequiredArg();
    OptionSpec<String> input = opts.accepts("input", "Input folder").withRequiredArg();
    OptionSet optionSet = opts.parse(strings);
    if (!optionSet.has(help) && optionSet.hasOptions()) {
        Path path = Paths.get(output.value(optionSet));
        boolean genAll = optionSet.has(all);
        boolean genClient = genAll || optionSet.has(client);
        boolean genServer = genAll || optionSet.has(server);
        boolean genDev = genAll || optionSet.has(dev);
        boolean genReports = genAll || optionSet.has(reports);
        boolean genValidate = genAll || optionSet.has(validate);
        FabricLoader loader = FabricLoader.getInstance();
        List<EntrypointContainer<ToymakerEntrypoint>> initializers = loader.getEntrypointContainers("toymaker", ToymakerEntrypoint.class);
        if (initializers.isEmpty()) {
            LOGGER.error("No data generators were initialized!");
        } else {
            for (EntrypointContainer<ToymakerEntrypoint> initializer : initializers) {
                ModMetadata meta = initializer.getProvider().getMetadata();
                if (TARGET_MOD_ID != null && !meta.getId().equals(TARGET_MOD_ID))
                    continue;
                LOGGER.info("Initializing data generator for " + meta.getId());
                initializer.getEntrypoint().onInitializeToymaker();
            }
        }
        DataGenerator gen = create(path, optionSet.valuesOf(input).stream().map(Paths::get).collect(Collectors.toList()), genClient, genServer, genDev, genReports, genValidate);
        DataGenAccess access = (DataGenAccess) gen;
        access.run(config -> optionSet.valuesOf(extra).stream().map(Paths::get).forEach(config::addCopyPath));
    } else {
        opts.printHelpOn(System.out);
    }
}
Also used : Path(java.nio.file.Path) FabricLoader(net.fabricmc.loader.api.FabricLoader) OptionParser(joptsimple.OptionParser) EntrypointContainer(net.fabricmc.loader.api.entrypoint.EntrypointContainer) ModMetadata(net.fabricmc.loader.api.metadata.ModMetadata) DataGenerator(net.minecraft.data.DataGenerator) Paths(java.nio.file.Paths) OptionSet(joptsimple.OptionSet) ToymakerEntrypoint(net.moddingplayground.frame.api.toymaker.v0.ToymakerEntrypoint)

Example 5 with ModMetadata

use of net.fabricmc.loader.api.metadata.ModMetadata in project meteor-client by MeteorDevelopment.

the class AddonManager method init.

@Init(stage = InitStage.Pre)
public static void init() {
    // Meteor pseudo addon
    {
        METEOR = new MeteorAddon() {

            @Override
            public void onInitialize() {
            }
        };
        ModMetadata metadata = FabricLoader.getInstance().getModContainer("meteor-client").get().getMetadata();
        METEOR.name = metadata.getName();
        METEOR.authors = new String[metadata.getAuthors().size()];
        if (metadata.containsCustomValue("meteor-client:color"))
            METEOR.color.parse(metadata.getCustomValue("meteor-client:color").getAsString());
        int i = 0;
        for (Person author : metadata.getAuthors()) {
            METEOR.authors[i++] = author.getName();
        }
    }
    // Addons
    for (EntrypointContainer<MeteorAddon> entrypoint : FabricLoader.getInstance().getEntrypointContainers("meteor", MeteorAddon.class)) {
        ModMetadata metadata = entrypoint.getProvider().getMetadata();
        MeteorAddon addon = entrypoint.getEntrypoint();
        addon.name = metadata.getName();
        addon.authors = new String[metadata.getAuthors().size()];
        if (metadata.containsCustomValue("meteor-client:color"))
            addon.color.parse(metadata.getCustomValue("meteor-client:color").getAsString());
        int i = 0;
        for (Person author : metadata.getAuthors()) {
            addon.authors[i++] = author.getName();
        }
        ADDONS.add(addon);
    }
}
Also used : ModMetadata(net.fabricmc.loader.api.metadata.ModMetadata) Person(net.fabricmc.loader.api.metadata.Person) Init(meteordevelopment.meteorclient.utils.Init)

Aggregations

ModMetadata (net.fabricmc.loader.api.metadata.ModMetadata)7 ModContainer (net.fabricmc.loader.api.ModContainer)3 FabricLoader (net.fabricmc.loader.api.FabricLoader)2 EntrypointContainer (net.fabricmc.loader.api.entrypoint.EntrypointContainer)2 EventListener (net.mine_diver.unsafeevents.listener.EventListener)2 Iterables (com.google.common.collect.Iterables)1 LinkedHashMultimap (com.google.common.collect.LinkedHashMultimap)1 Multimap (com.google.common.collect.Multimap)1 ModMenuApi (com.terraformersmc.modmenu.api.ModMenuApi)1 GuiConfigsBase (fi.dy.masa.malilib.gui.GuiConfigsBase)1 File (java.io.File)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 java.util (java.util)1 Collection (java.util.Collection)1 Map (java.util.Map)1 BiConsumer (java.util.function.BiConsumer)1 IntConsumer (java.util.function.IntConsumer)1 Supplier (java.util.function.Supplier)1 java.util.stream (java.util.stream)1