▶️ ЗАБЕРИ СВОИ 8 ПОДАРКОВ 🎁 ПРИ СОЗДАНИИ СВОЕГО МАЙНКРАФТ СЕРВЕРА
Моды/MenuKit
MenuKit

MenuKit

UI library for Fabric mods: HUD panels, widgets, layouts, region anchoring, modal overlays. Client-only.

Оцените первым
2.1K
1

MenuKit

MenuKit is a UI library for Fabric mods. It provides reusable interface components and the systems that place them on screen. Mods build menus, HUD overlays, slots, and in-game UI with it instead of writing Minecraft interface code from scratch.

It ships as two artifacts from this repository:

ArtifactRuns onAdds
menukitClient onlyPanels, elements, HUD panels, placement on vanilla screens, standalone screens
menukit-containersClient and serverCreated slots, custom container menus, per-slot state, storage attachments

menukit-containers depends on menukit. A mod that needs no slots depends on menukit alone and stays client-only.

Components: buttons, toggles, checkboxes, radio buttons, sliders, dropdowns (single and multi-select), text fields, labels, tooltips, icons, item displays, progress bars, dividers, and scroll containers. Containers adds slots.

What it does:

  • Places UI in four contexts with one set of components: the HUD, vanilla menu screens, named slot groups, and standalone screens.
  • Groups components into panels, each a bounded region that renders, takes input, and shows or hides as a unit.
  • Positions panels by screen region and resizes them to fit automatically, wrapping and scrolling as needed, at any GUI scale.
  • Lets more than one mod add UI to the same screen without conflict: panels sharing a region stack in order instead of overlapping.
  • Creates real, server-synced slots as UI components and shows them on every container screen without per-screen setup.
  • 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 become eleven, one per gesture, plain clicks included, and a mod can add its own. Each has a display name and a description. A slot answers for itself first, then its group, then its category, and a locking mod can veto any of them. Every operation checks SlotOperations.allows before it acts, and a click a mod sends counts as the operation it was sent for.
  • Attaches per-slot state to any slot, private per player or shared across viewers, stored on the slot's owner and readable with /data get.
  • Handles modal overlays, click-through prohibition, recipe-book awareness, and cursor stability across screen changes.

Its types are vanilla types (a MenuKit slot is a real Slot). Requires Fabric.

Install

repositories {
    maven { url 'https://api.modrinth.com/maven' }
}
dependencies {
    modImplementation 'maven.modrinth:menukit:5.1.0+26.2'
    // Only if the mod creates slots or custom menus. Pulls in menukit transitively.
    modImplementation 'maven.modrinth:menukit-containers:5.1.0+26.2'
}

Declare what you use in fabric.mod.json, with both bounds (why):

"depends": { "menukit": ">=5.1.0 <6.0.0" }
"depends": { "menukit": ">=5.1.0 <6.0.0", "menukit-containers": ">=5.1.0 <6.0.0" }

Example

A HUD readout, registered once from the client entry point:

MKHudPanel.builder("mymod:readout")
        .anchor(MKHudAnchor.CENTER, 0, 20)
        .autoSize().padding(4)
        .hideInScreen()
        .text(0, 0, () -> "Hello from MenuKit")
        .build();

Nine synced pocket slots on every container screen, registered once from the common entry point (Containers):

public static final PlayerStorageAttachment<NonNullList<ItemStack>> POCKETS =
        StorageAttachment.playerAttached("mymod", "pockets", 9);

MKCContainerPanel.define("mymod:pockets")
        .at(OutsideRegion.LEFT_ALIGN_TOP, 7)
        .style(PanelStyle.RAISED)
        .addSlot(SlotSpec.at("pockets", SlotGroupCategory.PLAYER_INVENTORY).count(9)
                .storage(player -> POCKETS.bind(player)))
        .register();

Docs

  • Getting started: dependency, one HUD panel, one inventory-screen panel.
  • Concepts: panels, elements, regions, the four contexts, slots, addresses.
  • Recipes: the common tasks, with samples from shipping mods.
  • Limits: what MenuKit does not do and the open gaps.
  • Reference: the generated javadoc for both artifacts.

The validator-mk and validator-mkc mods in the same workspace are the reference consumers, with compiling usage of every primitive.

Repository layout

  • menukit/: the menukit artifact.
  • menukit-containers/: the menukit-containers artifact.
  • docs/: the guides above.

Both artifacts build from the workspace root: ./gradlew :menukit:build :menukit-containers:build.

Upgrading

To 5.1.0

Nothing breaks. SlotSpec.quickMove(...) and MKCBehaviorKeys.QUICK_MOVE are deprecated for removal in 6.0.0; declare BehaviorKeys.SHIFT_CLICK_OUT and SHIFT_CLICK_IN instead.

To 5.0.0

Four region enums are two, and two bounds records are one. Replace the type names; the constants inside are unchanged.

WasIs
MenuRegion, SlotGroupRegionOutsideRegion
HudRegion, ScreenRegionInsideRegion
ScreenBounds, SlotGroupBoundsReference
HudRegion.CENTER_CROSSHAIR_CLEARANCERegionConstants.CENTER_CROSSHAIR_CLEARANCE

With Containers, every created slot group declares a SlotGroupCategory: SlotSpec.at(id, category), MKCSlots.onto(...).category(...), and PanelBuilder.group(id, category, storage). A group without one fails at runtime on the first menu it opens. Each 5.0.0 changelog lists the full set.

To 4.0.0

Vanilla draws every slot; MenuKit runs no slot pass of its own. Two public shapes changed:

  • CreatedSlotResolver.resolve returns the live in-menu Slot instead of a position. Read x and y off the returned slot.
  • SlotRendering keeps the frame helper and its constants. The item-drawing helpers are gone, because vanilla draws the item.

A mod that only builds panels, elements, or slots through the documented builders needs no change. concepts.md describes the rendering model.

To 3.0.0

The Java package moved from com.trevorschoeny.menukit to com.trevlar.menukit. Replace the prefix in every import. No class or method names changed.

License

MIT. See LICENSE.

Issues

github.com/trevorschoeny/menukit/issues.

Партнёрский материал

Как поиграть с друзьями с модом MenuKit?

Мод MenuKit куда интереснее в компании: поднимите сервер Майнкрафт с уже установленным модом, позовите друзей и играйте по своим правилам. Хостинг Майнкрафт для мода MenuKit будет готов за пару минут - BungeeHost сделает всё за вас.

Часто задаваемые вопросы

Совместимость

Minecraft: Java Edition

26.2.x1.21.x

Платформы

Поддерживаемые окружения

Клиент

Зависимости

Ссылки

Создатели

Детали

Лицензия:
Опубликован:5 месяцев назад
Обновлён:3 дня назад
Главная