### Assign Mod Badges Source: https://github.com/terraformersmc/modmenu/wiki/API Demonstrates how to manually assign library or deprecated badges to a mod via the custom metadata object. ```json "custom": { "modmenu": { "badges": [ "library", "deprecated" ] } } ``` -------------------------------- ### Utilize ModMenuApi Helpers Source: https://context7.com/terraformersmc/modmenu/llms.txt Provides examples of using static helper methods in ModMenuApi to programmatically create the Mods screen and generate localized button text. These utilities simplify UI integration for custom mod menus. ```java import com.terraformersmc.modmenu.api.ModMenuApi; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; Screen currentScreen = minecraft.screen; Screen modsScreen = ModMenuApi.createModsScreen(currentScreen); minecraft.setScreen(modsScreen); Component buttonText = ModMenuApi.createModsButtonText(); Button modsButton = Button.builder( ModMenuApi.createModsButtonText(), button -> minecraft.setScreen(ModMenuApi.createModsScreen(this)) ).bounds(x, y, width, height).build(); ``` -------------------------------- ### ConfigScreenFactory for Creating Config Screens Source: https://context7.com/terraformersmc/modmenu/llms.txt This Java code illustrates the `ConfigScreenFactory` interface, used to create configuration screens for your mod. It shows a simple implementation and its usage with lambda expressions or method references within a `ModMenuApi` implementation. An example `MyConfigScreen` class is also provided. ```java package com.example.mod; import com.terraformersmc.modmenu.api.ConfigScreenFactory; import net.minecraft.client.gui.screens.Screen; // Simple implementation public class MyConfigScreenFactory implements ConfigScreenFactory { @Override public MyConfigScreen create(Screen parent) { return new MyConfigScreen(parent); } } // Usage with lambda in ModMenuApi implementation public class MyModMenuImpl implements ModMenuApi { @Override public ConfigScreenFactory getModConfigScreenFactory() { // Lambda syntax return parent -> new MyConfigScreen(parent); // Or method reference if constructor matches // return MyConfigScreen::new; } } // Example config screen class public class MyConfigScreen extends Screen { private final Screen parent; public MyConfigScreen(Screen parent) { super(Component.literal("My Mod Config")); this.parent = parent; } @Override public void onClose() { this.minecraft.setScreen(parent); } } ``` -------------------------------- ### Localize Mod Metadata Source: https://github.com/terraformersmc/modmenu/wiki/API Provides translations for mod names, descriptions, and summaries using specific localization keys in your language files. ```json "modmenu.nameTranslation.modmenu": "Menu o' mods!" "modmenu.descriptionTranslation.modmenu": "Menu o' mods ye installed matey!" ``` -------------------------------- ### Example Mod Menu Search Keyword Usage Source: https://context7.com/terraformersmc/modmenu/llms.txt Utilize special search terms in the Mod Menu's search bar to filter mods based on characteristics like type, compatibility, or status. These keywords allow for quick identification of mods meeting specific criteria. ```text # Example searches in the Mods screen search bar: library # Shows all library mods config # Shows all configurable mods updates # Shows mods with available updates clientside # Shows client-only mods deprecated # Shows deprecated mods ``` -------------------------------- ### Register ModMenuApi Entrypoint Source: https://github.com/terraformersmc/modmenu/wiki/API Registers a Java class as a ModMenuApi implementation within the fabric.mod.json file to enable advanced API features. ```json "entrypoints": { "modmenu": [ "com.example.mod.ExampleModMenuApiImpl" ] } ``` -------------------------------- ### Implement Modpack Badges via Java API Source: https://github.com/terraformersmc/modmenu/wiki/API Uses the attachModpackBadges method to programmatically assign the 'modpack' badge to specific mods. ```java @Override public void attachModpackBadges(Consumer consumer) { consumer.accept("modmenu"); // Indicates that 'modmenu' is part of the modpack } ``` -------------------------------- ### Create Mods Screen Instance (Java) Source: https://github.com/terraformersmc/modmenu/blob/26.1/README.md The ModMenuApi provides a static helper method `createModsScreen` to get an instance of the main Mods screen. This can be used by mods to link to the Mods list. ```java import com.terraformersmc.modmenu.util.ModMenuApiHelper; import net.minecraft.client.gui.screen.Screen; // ... inside a method where 'previousScreen' is available Screen modsScreen = ModMenuApiHelper.createModsScreen(previousScreen); ``` -------------------------------- ### Configure Mod Menu Dependency in Gradle Source: https://github.com/terraformersmc/modmenu/wiki/API Adds the Terraformers Maven repository and the Mod Menu dependency to a Fabric project. Requires a project property for the version number. ```gradle repositories { maven { name = "Terraformers" url = "https://maven.terraformersmc.com/" } } dependencies { modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}") } ``` ```properties modmenu_version=9.0.0 ``` -------------------------------- ### Define Custom Mod Menu Metadata Source: https://github.com/terraformersmc/modmenu/wiki/API Configures custom Mod Menu settings such as links, badges, and parent mod information within the fabric.mod.json file under the custom object. ```json "custom": { "modmenu": { "links": { "modmenu.discord": "https://discord.gg/jEGF5fb" }, "badges": [ "library", "deprecated" ], "parent": { "id": "example-api", "name": "Example API", "description": "Modular example library", "icon": "assets/example-api-module-v1/parent_icon.png", "badges": [ "library" ] }, "update_checker": true } } ``` -------------------------------- ### Define Mod Parenting in fabric.mod.json Source: https://github.com/terraformersmc/modmenu/wiki/API Configures a mod to appear as a child of another mod or a dummy parent. This is useful for grouping modularized mods under a single parent entry. ```json "custom": { "modmenu": { "parent": "flamingo" } } ``` ```json "custom": { "modmenu": { "parent": { "id": "this-mod-isnt-real", "name": "Fake Mod", "description": "Do cool stuff with this fake mod", "icon": "assets/real-mod/fake-mod-icon.png", "badges": [ "library" ] } } } ``` -------------------------------- ### Disable Mod Menu Update Checker Source: https://github.com/terraformersmc/modmenu/wiki/API Disables the automatic update checking feature for a specific mod by setting the update_checker flag to false in the metadata. ```json "custom": { "modmenu": { "update_checker": false } } ``` -------------------------------- ### Implement Custom UpdateChecker Source: https://context7.com/terraformersmc/modmenu/llms.txt Demonstrates how to implement the UpdateChecker interface to perform custom version checks. The implementation runs in a separate thread, allowing for blocking network calls to fetch version information. ```java package com.example.mod; import com.terraformersmc.modmenu.api.UpdateChannel; import com.terraformersmc.modmenu.api.UpdateChecker; import com.terraformersmc.modmenu.api.UpdateInfo; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.Nullable; public class MyCustomUpdateChecker implements UpdateChecker { @Override @Nullable public UpdateInfo checkForUpdates() { String currentVersion = "1.0.0"; UpdateChannel userPreference = UpdateChannel.getUserPreference(); VersionInfo latestVersion = fetchLatestVersion(userPreference); if (latestVersion != null && isNewerVersion(currentVersion, latestVersion.version)) { return new UpdateInfo() { @Override public boolean isUpdateAvailable() { return true; } @Override @Nullable public Component getUpdateMessage() { return Component.literal("Update " + latestVersion.version + " available!"); } @Override public String getDownloadLink() { return latestVersion.downloadUrl; } @Override public UpdateChannel getUpdateChannel() { return latestVersion.channel; } }; } return null; } private VersionInfo fetchLatestVersion(UpdateChannel channel) { return null; } private boolean isNewerVersion(String current, String latest) { return false; } private record VersionInfo(String version, String downloadUrl, UpdateChannel channel) {} } ``` -------------------------------- ### Configure Dummy Parent for Modular Mods Source: https://context7.com/terraformersmc/modmenu/llms.txt Create a virtual parent mod configuration to group related child mods. This allows for a unified presentation in Mod Menu, where the parent's details are shared across multiple child mods. Ensure the parent ID is consistent across all related configurations. ```json { "schemaVersion": 1, "id": "example-api-core", "name": "Example API Core", "custom": { "modmenu": { "parent": { "id": "example-api", "name": "Example API", "description": "A modular API library for Minecraft mods", "icon": "assets/example-api-core/parent_icon.png", "badges": ["library"] } } } } ``` ```json { "id": "example-api-networking", "name": "Example API Networking", "custom": { "modmenu": { "parent": { "id": "example-api", "name": "Example API", "description": "A modular API library for Minecraft mods", "icon": "assets/example-api-networking/parent_icon.png", "badges": ["library"] } } } } ``` -------------------------------- ### Implement ModMenuApi and Register Entrypoint (JSON) Source: https://github.com/terraformersmc/modmenu/blob/26.1/README.md To use the Mod Menu API, implement the ModMenuApi interface in your mod and register it as a 'modmenu' entrypoint in your fabric.mod.json file. This tells Mod Menu where to find your API implementation. ```json { "entrypoints": { "modmenu": [ "com.example.mod.ExampleModMenuApiImpl" ] } } ``` -------------------------------- ### Provide Config Screens for Other Mods (Java) Source: https://github.com/terraformersmc/modmenu/blob/26.1/README.md Mods can also provide configuration screens for other mods by implementing the `getProvidedConfigScreenFactories` method. This is useful for libraries like Cloth Config to offer their services to other mods. ```java import com.terraformersmc.modmenu.api.ModMenuApi; import net.minecraft.client.gui.screen.Screen; import java.util.Map; import java.util.function.Function; public class ExampleModMenuApiImpl implements ModMenuApi { @Override public Map> getProvidedConfigScreenFactories() { return Map.of("cloth_config", parent -> new MyClothConfigScreen(parent)); } } ``` -------------------------------- ### Implement ModMenuApi for Mod Menu Integration Source: https://context7.com/terraformersmc/modmenu/llms.txt This Java code demonstrates how to implement the `ModMenuApi` interface to integrate your mod with Mod Menu. It covers providing configuration screens, custom update checkers, and managing modpack badges. The implementation needs to be registered as a 'modmenu' entrypoint in `fabric.mod.json`. ```java package com.example.mod; import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ModMenuApi; import com.terraformersmc.modmenu.api.UpdateChecker; import net.minecraft.client.gui.screens.Screen; import java.util.Map; import java.util.function.Consumer; public class ExampleModMenuApiImpl implements ModMenuApi { @Override public ConfigScreenFactory getModConfigScreenFactory() { // Return a factory that creates your config screen return parent -> new MyModConfigScreen(parent); } @Override public UpdateChecker getUpdateChecker() { // Return custom update checker or null for Modrinth auto-check return new MyCustomUpdateChecker(); } @Override public Map> getProvidedConfigScreenFactories() { // Provide config screens for other mods (e.g., for config library mods) return Map.of( "other-mod-id", parent -> new OtherModConfigScreen(parent), "another-mod", parent -> new AnotherModConfigScreen(parent) ); } @Override public Map getProvidedUpdateCheckers() { // Provide update checkers for other mods return Map.of( "dependency-mod", new DependencyUpdateChecker() ); } @Override public void attachModpackBadges(Consumer consumer) { // Mark mods as part of a modpack consumer.accept("some-mod-id"); consumer.accept("another-mod-id"); } } ``` ```json { "entrypoints": { "modmenu": ["com.example.mod.ExampleModMenuApiImpl"] } } ``` -------------------------------- ### ConfigScreenFactory Interface Source: https://context7.com/terraformersmc/modmenu/llms.txt A functional interface used to instantiate configuration screens when a user interacts with the mod's configuration button in the menu. ```APIDOC ## Interface ConfigScreenFactory ### Description A functional interface for creating configuration screens. The `create` method is called when the user clicks the config button for a mod. ### Method - **create(Screen parent)**: Returns an instance of the configuration screen, typically passing the `parent` screen to allow for proper navigation back to the mod list. ### Implementation Example ```java public class MyConfigScreenFactory implements ConfigScreenFactory { @Override public MyConfigScreen create(Screen parent) { return new MyConfigScreen(parent); } } ``` ``` -------------------------------- ### ModMenuApi Interface Source: https://context7.com/terraformersmc/modmenu/llms.txt The primary entrypoint interface for Mod Menu integration. Implement this to provide configuration screens, custom update checkers, and modpack badge associations. ```APIDOC ## Interface ModMenuApi ### Description The main Java interface for integrating with Mod Menu. Implement this interface and register it as an entrypoint in your `fabric.mod.json` to provide config screens and customize mod behavior. ### Registration Register the implementation in `fabric.mod.json` under the `modmenu` entrypoint key: ```json { "entrypoints": { "modmenu": ["com.example.mod.ExampleModMenuApiImpl"] } } ``` ### Methods - **getModConfigScreenFactory()**: Returns a `ConfigScreenFactory` for the current mod. - **getUpdateChecker()**: Returns a custom `UpdateChecker` or null to default to Modrinth. - **getProvidedConfigScreenFactories()**: Returns a map of mod IDs to their respective `ConfigScreenFactory` (useful for library mods). - **getProvidedUpdateCheckers()**: Returns a map of mod IDs to their respective `UpdateChecker`. - **attachModpackBadges(Consumer consumer)**: Allows marking specific mod IDs with modpack badges. ``` -------------------------------- ### Translate Mod Names and Descriptions using JSON Source: https://context7.com/terraformersmc/modmenu/llms.txt Localize your mod's name, description, and summary for different languages by creating language-specific JSON files in the `assets//lang/` directory. This enables multi-language support without modifying Java code. ```json // assets/yourmod/lang/en_us.json (English) { "modmenu.nameTranslation.yourmod": "Your Mod", "modmenu.descriptionTranslation.yourmod": "A fantastic mod that does amazing things.", "modmenu.summaryTranslation.yourmod": "Does amazing things." } // assets/yourmod/lang/es_es.json (Spanish) { "modmenu.nameTranslation.yourmod": "Tu Mod", "modmenu.descriptionTranslation.yourmod": "Un mod fantástico que hace cosas increíbles.", "modmenu.summaryTranslation.yourmod": "Hace cosas increíbles." } // assets/yourmod/lang/en_pt.json (Pirate Speak) { "modmenu.nameTranslation.yourmod": "Yer Mod", "modmenu.descriptionTranslation.yourmod": "A fine mod that does amazin' things, matey!", "modmenu.summaryTranslation.yourmod": "Does amazin' things, arr!" } // Custom link translations { "yourmod.custom_support": "Support Forum", "yourmod.custom_docs": "Documentation" } ``` -------------------------------- ### Integrate Mod Menu via Gradle Source: https://github.com/terraformersmc/modmenu/blob/26.1/README.md Configures the build environment to include Mod Menu as a compile-time dependency, enabling the use of the Java API. ```gradle repositories { maven { name = "Terraformers" url = "https://maven.terraformersmc.com/" } } dependencies { implementation("com.terraformersmc:modmenu:${project.modmenu_version}") } ``` ```properties modmenu_version=VERSION_NUMBER_HERE ``` -------------------------------- ### Provide Custom Mod Config Screen (Java) Source: https://github.com/terraformersmc/modmenu/blob/26.1/README.md Mods can offer a custom configuration screen by implementing the `getModConfigScreenFactory` method in their ModMenuApi implementation. This allows users to configure mod settings directly through Mod Menu. ```java import com.terraformersmc.modmenu.api.ModMenuApi; import net.minecraft.client.gui.screen.Screen; import java.util.function.Function; public class ExampleModMenuApiImpl implements ModMenuApi { @Override public Function getModConfigScreenFactory() { return parent -> new MyCustomConfigScreen(parent); } } ``` -------------------------------- ### Configure Quilt Mod JSON Metadata for Mod Menu Source: https://context7.com/terraformersmc/modmenu/llms.txt For Quilt mods, Mod Menu metadata is configured directly in the root of the `mods.toml` or `quilt.mod.json` file, rather than within a `custom` object. This includes links, badges, and parent mod information. ```json { "schema_version": 1, "quilt_loader": { "id": "example-mod", "version": "1.0.0", "metadata": { "name": "Example Mod", "description": "An example Quilt mod." } }, "modmenu": { "links": { "modmenu.discord": "https://discord.gg/example" }, "badges": ["library"], "parent": "parent-mod-id", "update_checker": true } } ``` -------------------------------- ### Add Mod Menu Dependency in Gradle Source: https://context7.com/terraformersmc/modmenu/llms.txt This snippet shows how to add Mod Menu as a dependency to your Gradle project. It includes repository configuration and dependency declarations for different Minecraft versions and mapping scenarios. Ensure `modmenu_version` is defined in `gradle.properties`. ```gradle // build.gradle repositories { maven { name = "Terraformers" url = "https://maven.terraformersmc.com/" } } dependencies { // For Minecraft 26.1+ without mappings implementation("com.terraformersmc:modmenu:${project.modmenu_version}") // For earlier versions or when using mappings // modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}") // Use modCompileOnly if you only want compile-time dependency // modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}") } ``` ```properties # gradle.properties modmenu_version=9.0.0 ``` -------------------------------- ### Configure Mod Translations via JSON Source: https://github.com/terraformersmc/modmenu/blob/26.1/README.md Define localized names, summaries, and descriptions for your mod by adding specific keys to your language files. Replace the mod ID suffix with your own mod's unique identifier. ```json { "modmenu.nameTranslation.modid": "Your Mod Name", "modmenu.descriptionTranslation.modid": "Your mod description here.", "modmenu.summaryTranslation.modid": "A short summary of your mod." } ``` -------------------------------- ### Manage Update Channels Source: https://context7.com/terraformersmc/modmenu/llms.txt Explains how to use the UpdateChannel enum to filter update notifications based on user stability preferences. Developers should compare channel ordinals to ensure updates respect the user's configured channel. ```java import com.terraformersmc.modmenu.api.UpdateChannel; UpdateChannel.ALPHA; UpdateChannel.BETA; UpdateChannel.RELEASE; UpdateChannel userPreference = UpdateChannel.getUserPreference(); public UpdateInfo checkForUpdates() { UpdateChannel userPref = UpdateChannel.getUserPreference(); if (availableUpdate.channel.ordinal() >= userPref.ordinal()) { return availableUpdate; } return null; } ``` -------------------------------- ### Configure fabric.mod.json Metadata for Mod Menu Source: https://context7.com/terraformersmc/modmenu/llms.txt Define your mod's appearance and links within the Mod Menu using the 'custom.modmenu' section in fabric.mod.json. This configuration allows for specifying Discord links, wikis, donation pages, and badges without requiring Java code. ```json { "schemaVersion": 1, "id": "example-mod", "name": "Example Mod", "version": "1.0.0", "environment": "client", "description": "An example mod with Mod Menu integration.", "authors": ["Developer Name"], "contact": { "homepage": "https://example.com", "sources": "https://github.com/example/mod", "issues": "https://github.com/example/mod/issues" }, "custom": { "modmenu": { "links": { "modmenu.discord": "https://discord.gg/example", "modmenu.wiki": "https://wiki.example.com", "modmenu.kofi": "https://ko-fi.com/example", "modmenu.patreon": "https://patreon.com/example", "modmenu.modrinth": "https://modrinth.com/mod/example", "modmenu.curseforge": "https://curseforge.com/minecraft/mc-mods/example", "example.custom_link": "https://custom.example.com" }, "badges": ["library", "deprecated"], "parent": "parent-mod-id", "update_checker": true } } } ``` -------------------------------- ### Create Mods Button Text (Java) Source: https://github.com/terraformersmc/modmenu/blob/26.1/README.md A static helper method `createModsButtonText` is available to retrieve the text that would typically be displayed on a Mod Menu Mods button. This can be used for consistency in custom UI elements. ```java import com.terraformersmc.modmenu.util.ModMenuApiHelper; import net.minecraft.text.Text; Text modsButtonText = ModMenuApiHelper.createModsButtonText(); ``` -------------------------------- ### Configure Mod Menu Links in fabric.mod.json Source: https://github.com/terraformersmc/modmenu/blob/26.1/README.md Defines custom hyperlinks in the mod description using the links object. Keys correspond to translation keys, allowing for localized link text. ```json "custom": { "modmenu": { "links": { "modmenu.discord": "https://discord.gg/jEGF5fb" } } } ``` -------------------------------- ### Configure Mod Metadata in fabric.mod.json Source: https://github.com/terraformersmc/modmenu/blob/26.1/README.md Add custom metadata to your fabric.mod.json file to define links, badges, parent mod relationships, and enable the update checker. This allows Mod Menu to display additional information and categorize your mod correctly. ```json5 { "custom": { "modmenu": { "links": { "modmenu.discord": "https://discord.gg/jEGF5fb" }, "badges": [ "library", "deprecated" ], "parent": { "id": "example-api", "name": "Example API", "description": "Modular example library", "icon": "assets/example-api-module-v1/parent_icon.png", "badges": [ "library" ] }, "update_checker": true } } } ``` -------------------------------- ### Disable Mod Menu Update Checker (JSON) Source: https://context7.com/terraformersmc/modmenu/llms.txt This JSON snippet disables the automatic Modrinth update checker for your mod within Mod Menu. Ensure this configuration is correctly placed within your project's JSON files to take effect. No external dependencies are required for this specific configuration. ```json { "custom": { "modmenu": { "update_checker": false } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.