SlotKit
A Fabric library for finding and acting on the slots in any menu, and for building real slots that persist and sync.
- Загрузчики
- Fabric
- Скачиваний на Modrinth
- 820
- Подписчиков на Modrinth
- 0
- версий
- 15
- Обновлён
- 17 октября 202617 окт.
- Опубликован
- в 2026
Коротко о моде
Нужен в игре; на сервере — по желанию
SlotKit
SlotKit is a slot library for Fabric mods, built on MenuKit. A mod uses it to find and act on the slots in any menu, vanilla or modded, or to build real slots and custom menus that persist and sync. I built it for my own mods and opened it up so other modders can use it too.
If you're a player and another mod asked for SlotKit, install it alongside that mod and you're done.
SlotKit was called MenuKit: Containers. Mods built for Containers need an update, and the upgrading guide has the steps. MenuKit: Containers 6.2.0 is still in this project's version list.
Features
SlotKit has two tiers. A mod needs SlotKit on the other side only for the second.
| Tier | Needs SlotKit on | Adds |
|---|---|---|
| Client | The client only. It works on any server, vanilla included. | Slot groups and categories in every menu, slot operations, vetoes and gates, and panels placed against a slot group |
| Client and server | Both sides | Created slots, custom container menus, storage attachments, and per-slot state |
- Every slot group, vanilla or created, is published under a category any mod can read, with or without a menu open.
- Each thing that can be done to a slot is named as an operation. Vanilla has 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.
- A MenuKit panel can be placed against a slot group, so it shows on every screen with that group. That includes the survival inventory, every chest, and every other container.
- Slots in a MenuKit scroll area clip to it, so a long grid of slots can scroll.
- Created slots are UI components. A pocket, an extra equipment slot, or a satchel is each a real
Slot, synced by vanilla's protocol, and shows on every container screen with no per-screen setup. - Custom container menus are built from MenuKit panels.
- Created slots behave like vanilla ones in creative and survival, on death, and with Curse of Binding and Mending.
- Per-slot state can be attached to any slot, either private to each player or shared by everyone viewing it. The server checks every write a client sends. The state is stored on the slot's owner (a player, block, entity, or item), where
/data getcan read it. - Each side checks which mods the other has before the world loads. A server refuses only players missing a mod that builds slots, and names the mods to install, with links. Everyone else joins.
- Worlds and player files saved with MenuKit: Containers load with no conversion, and shulker boxes keep their contents and slot state.
Example
A panel above the player inventory, registered once from the client entry point. It uses the client tier, so it works on any server.
Panel panel = Panel.builder("mymod:toolbar")
.style(PanelStyle.NONE)
.elements(toolbarButtons)
.position(PanelPosition.region(OutsideRegion.TOP_ALIGN_RIGHT))
.visibleWhen(() -> config.toolbar)
.build();
new SlotGroupPanelAdapter(panel)
.on(SlotGroupCategory.PLAYER_INVENTORY);Nine synced pocket slots on every container screen, registered once from the common entry point. These need SlotKit on both sides.
public static final PlayerStorageAttachment<NonNullList<ItemStack>> POCKETS =
StorageAttachment.playerAttached("mymod", "pockets", 9);ContainerPanel.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();Getting started
Minecraft 26.3 is unobfuscated, so SlotKit goes on the plain implementation configuration, beside MenuKit.
repositories {
maven { url 'https://api.modrinth.com/maven' }
}
dependencies {
implementation 'maven.modrinth:menukit:7.2.0+26.3'
implementation 'maven.modrinth:xQUBXV8I:1.1.1+26.3' // SlotKit
}xQUBXV8I is SlotKit's Modrinth project id. It resolves whatever the project's slug is.
Declare both in fabric.mod.json, each against its own version, with both bounds (why). Separate the bounds with a space, since Fabric doesn't read a comma there.
"depends": { "menukit": ">=7.2.0 <8.0.0", "slotkit": ">=1.1.0 <2.0.0" }Players install SlotKit as its own mod, next to the mods that use it. List it as a required dependency on the mod's Modrinth page so it's installed with them.
Requirements
- MenuKit 7.2.0 or newer, below 8.0.0. SlotKit builds its panels and slot drawing on MenuKit.
- Fabric API.
Compatibility
Minecraft 26.3 with Fabric. Install SlotKit on the client. It's optional on the server, and needed there only when a mod that builds slots is installed. SlotKit replaces MenuKit: Containers, so the two can't be installed together, and it can't be installed with Inventory Max either.
Used by
How to use
This guide follows the order a mod usually meets SlotKit, from finding slots on the client to building slots that need both sides. Each part links to the full developer docs. Concepts defines every term, and Recipes has a worked example for each common task.
The public API
The API is every type in a package named api, which is com.trevlar.slotkit.api.*. The version contract covers those. Every other package is internal and can change in any release, a patch included. A task that seems to need an internal type is a gap in the API, so open an issue for it. Versioning has what each part of a version number promises.
Declare which sides need SlotKit
A mod states in its fabric.mod.json whether it needs SlotKit on both sides.
"custom": { "slotkit": { "bothSides": "required" } }requiredis for a mod that builds slots or custom menus. A server with the mod admits only clients that have SlotKit and the mod.preferredis for a mod that works on one side and does more with both, such as shared slot state. Nobody is refused for it.- A mod with no
slotkitblock only finds and acts on slots. It works on any server and never causes a refusal.
Any other value throws when the mod loads. Declaring sides covers the handshake and every message a refused player sees.
Find slot groups
A slot group category is a name for a group of slots, such as PLAYER_INVENTORY, PLAYER_HOTBAR, CHEST_STORAGE, or FURNACE_INPUT. SlotGroupCategories.all() lists every category with no menu open, SlotGroupCategories.of(menu) lists the categories on a menu with their slots, and SlotGroupCategories.categoriesBySlot(menu) gives the category of each slot. SlotGroups lists individual groups, which can tell one mod's pockets apart from the main inventory when both declare PLAYER_INVENTORY. This is client tier. Slot group category has the full rules for naming and minting categories.
Place a panel against a slot group
SlotGroupPanelAdapter places a MenuKit panel against a slot group instead of a screen's frame, as in the first example above. Pass several categories to .on(...) to show the panel once per matching group. An adapter with no .on(...) fails at the first screen open, with the panel id in the message. This is client tier. See Recipes.
Allow, gate, and veto operations
An operation is something done to a slot. Vanilla's eleven are CLICK_TAKE, CLICK_PUT, SHIFT_CLICK_OUT, SHIFT_CLICK_IN, COLLECT, DRAG_FILL, HOTBAR_SWAP, OFFHAND_SWAP, DROP, DROP_STACK, and INVENTORY_INSERT, and every one is on by default.
- What a slot allows is decided by a cascade. A per-slot declaration wins over the slot's group, the group wins over its category, and the category wins over the key's default.
SlotOperations.inherent(category, operation, value)sets the category level. SlotOperations.veto(rule)registers a rule that can only say no, for a mod that is not the slot's author, such as a lock.SlotOperations.allows(menu, slot, player, operation)is the one check, and it passes when the cascade allows the operation and no veto refuses it.- A gate sets what a slot accepts and releases, and how many of an item it holds. It is set with
SlotSpec.gate(...)orWindow.slot(address).gate(...). - A mod adds its own operation by declaring a
BehaviorKey, publishing it withSlotOperations.define, and shipping a name and description in its lang file.
Operation and Gate cover roles, AppliesTo, and click tagging with SlotOperations.as. See also Block operations on a locked slot and Add an operation of your own.
Build created slots
A created slot is a real Slot a mod adds to a menu. ContainerPanel.define(id) creates slots on the player's inventory menu and shows them on every container screen, as in the second example above. Its contents persist through a StorageAttachment on the slot's owner, built with StorageAttachment.playerAttached(namespace, key, size) for a player or EphemeralStorage.of(size) for one menu session.
- The panel id's namespace is the mod's id.
definethrows at startup when it isn't, or when the mod doesn't declarerequired. The message names the panel and the line to add. SlotSpec.shiftClickIn(true)makes a group a shift-click target in the player's inventory, andSlotSpec.emptyIcon(...)draws an outline in its empty slots.ContainerPanel.Builder.on(...)places a slot panel against a slot group, such as above the offhand.
This needs SlotKit on both sides. See Created slot, Storage, and Put a slot above the offhand.
Scroll slots in a scroll area
A SlotElement inside a MenuKit ScrollContainer scrolls and clips like any other element. A slot across the edge of the scroll area draws, hovers, and takes clicks only where it shows. A mod that uses SlotElement needs no extra code for this.
Open a custom menu
CustomMenu.define(id, ...) builds a container menu with its own slots, laid out with MenuKit panels. The server decides which panels are shown, a player can toggle only a panel declared toggleable(), and a client can open the menu only while its validWhen holds. The same definition check as ContainerPanel applies. See Open a custom menu with its own slots.
Attach state to a slot
SlotState.register(id, codec, streamCodec, defaultValue, visibility, canWrite) creates a channel that stores one typed value per slot, separate from the slot's item. PRIVATE stores one value per viewer, and SHARED stores one value for everyone. A slot is named by an Address, which resolves after a menu reopens and on both sides. The server checks every write a client sends, and a SHARED channel refuses every client unless its canWrite rule allows them. See Slot state channel and Attach a flag to a slot.
Ask what the other side runs
Presence reports what the other side had when the player joined. On the client, Presence.serverHasSlotKit(), serverHas(modId), and serverHasChannel(channelId) answer about the server. On the server, Presence.clientHasSlotKit(player) and clientHas(player, modId) answer about a player. See Presence.
Know the limits
Limits lists what SlotKit doesn't do and the open gaps in this release, such as created slots in overlay panels.
Upgrade from MenuKit: Containers
Upgrading moves a mod from MenuKit: Containers or from MenuKit 6's slot code, with an import map and the two renames.
License
MIT.
Частые вопросы
Как установить SlotKit?
Установите Fabric под свою версию Minecraft, скачайте SlotKit под ту же версию и загрузчик, положите файл в папку mods и запустите игру с профилем загрузчика.
Для каких версий Minecraft есть SlotKit?
У SlotKit есть сборки для Minecraft 1.21.11, 26.2–26.3.
Нужен ли SlotKit на сервере?
Нужен в игре; на сервере — по желанию