Search in sources :

Example 1 with ModMenuApi

use of com.terraformersmc.modmenu.api.ModMenuApi 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)

Aggregations

ModMenuApi (com.terraformersmc.modmenu.api.ModMenuApi)1 GuiConfigsBase (fi.dy.masa.malilib.gui.GuiConfigsBase)1 ModMetadata (net.fabricmc.loader.api.metadata.ModMetadata)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 Screen (net.minecraft.client.gui.screen.Screen)1