← Назад к ресурсам

MenuKit

UI library for Fabric mods: panels, buttons, tabs and HUD readouts placed on any screen, plus slot groups and slot operations every mod can read.

Modrinth library

Описание

# MenuKit MenuKit is a UI library for Fabric mods. It provides the parts of a Minecraft interface (buttons, sliders, tabs, panels, HUD readouts, slots) and places them on screen, so a mod builds its menus and overlays without writing vanilla screen code from scratch. It ships as two artifacts from this repository: | Artifact | Runs on | Adds | |---|---|---| | `menukit` | Client and server (the UI draws on the client) | Panels, elements, HUD panels, placement on vanilla screens, standalone screens, slot groups and slot operations | | `menukit-containers` | Client and server, required on both | Created slots, custom container menus, per-slot state, storage attachments | `menukit-containers` depends on `menukit`. A mod that adds no slots depends on `menukit` alone and can stay client-only. A server running Containers requires it on every player's game. It checks before the world loads, and a player without it is told which two mods to install. Components: buttons, toggles, checkboxes, radio buttons, sliders, dropdowns (single and multi-select), text fields, labels, tooltips, icons, item displays (with an optional coloured outline), progress bars, dividers, scroll containers, runtime rows (`Flow`), collapsible sections and tabs. Containers adds slots. Every component has a builder with the same vocabulary (`at`, `size`, `visibleWhen`, `disabledWhen`, `tooltip`, `state`, `onClick`, `style`), and every control that shows a value reads and writes a field the mod owns. What it does: - Places UI in five contexts with one set of components: the HUD, container screens, other vanilla screens, named slot groups, and standalone screens. - Groups components into panels. A panel renders, takes input, and shows or hides as a unit. - Takes a panel's placement from one declaration on the panel, and sizes the panel to fit, wrapping and scrolling as needed, at any GUI scale. - Lets several mods add UI to the same screen. Panels sharing a region stack in priority order instead of overlapping, in the same order on every launch. - Makes what a panel covers inert. An opaque panel takes every point of its rectangle and a see-through one only its controls, so a slot or widget under a panel does not highlight, click or show a tooltip. - Publishes every slot group, vanilla or created, under a category any mod can read, with or without a menu open. - Names each thing that can be done to a slot as an operation. Vanilla's actions are eleven, one per gesture, and a mod can add its own. A slot answers for itself first, then its group, then its category, and a locking mod can veto any operation. - Creates real, server-synced slots as UI components and shows them on every container screen without per-screen setup (Containers). - Attaches per-slot state to any slot, private per player or shared, stored on the slot's owner. The server judges every write a client sends (Containers). - Gives its controls vanilla's click sound, narration and keyboard focus, and greys a whole panel at once with one `disabledWhen`. Its types are vanilla types. A created slot is a real `Slot`, and a custom menu is a real `AbstractContainerMenu`. Requires Fabric and Fabric API. ## Install Minecraft 26.2 is unobfuscated, so MenuKit goes on the plain `implementation` configuration: ```gradle repositories { maven { url 'https://api.modrinth.com/maven' } } dependencies { implementation 'maven.modrinth:menukit:6.0.0+26.2' // Only if the mod creates slots or custom menus. implementation 'maven.modrinth:menukit-containers:6.0.0+26.2' } ``` Declare what you use in `fabric.mod.json`, with both bounds ([why](https://github.com/trevorschoeny/menukit/blob/main/docs/versioning.md)): ```json "depends": { "menukit": ">=6.0.0 =6.0.0 =6.0.0