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

GUI API

Datapack-driven chest GUI system for Minecraft 1.21.1.

Оцените первым
57
0

GUI API — Fabric 1.21.8

A Fabric mod that lets datapacks define and open chest GUIs via JSON files.
No client mod required. No macros. No external dependencies beyond Fabric API.


Installation

  1. Drop guiapi-1.0.4.jar into your mods/ folder.
  2. Drop your datapack into world/datapacks/.
  3. Run /reload or /guiapi reload.

Optionally install Mod Menu to see loaded GUIs and visually edit them in-game!


Commands

CommandDescription
/guiapiShow help (same as /guiapi help)
/guiapi open <id>Open a GUI for yourself
/guiapi open <id> <targets>Open a GUI for target players
/guiapi listList all loaded GUI definitions
/guiapi reloadReload all datapack resources (including GUIs)
/guiapi var get <player> <key>Get a player's runtime variable
/guiapi var set <player> <key> <value>Set a player's runtime variable
/guiapi var clear <player>Clear all runtime variables for a player
/guiapi helpShow command and JSON field reference in-game

Permission level 2 (OP) required by default (configurable in Mod Menu).


File Location

GUI definition files go in:

data/<namespace>/gui/<name>.json

The GUI ID used in commands is <namespace>:<name> — matching the file path under gui/.


JSON Schema

Top-level fields

FieldTypeDefaultDescription
titlestring"GUI"Inventory title. Supports § color codes and placeholders.
rowsint 1–63Number of rows (9 slots each).
tick_rateint0Auto-refresh interval in ticks (e.g., 20 = 1s). Set 0 to disable.
close_on_movebooleanfalseIf true, closes screen if player walks away (> 1.5 blocks).
fillerobjectBackground filler configuration (see below).
on_openaction[][]Actions executed when the GUI is opened.
on_closeaction[][]Actions executed when the GUI is closed (any reason).
buttonsbutton[][]List of button definitions.

Filler fields

Any empty slot in the inventory is automatically populated with this background item.

"filler": {
  "item": "minecraft:gray_stained_glass_pane",
  "name": " ",
  "glint": false,
  "hide_tooltip": true
}

Button fields

FieldTypeDefaultDescription
slotint0Zero-based slot index (0–rows*9-1).
pageint0Which page this button appears on.
itemstring"minecraft:stone"Item ID.
namestring""Display name. Supports color codes and placeholders.
lorestring[][]Lore lines. Supports placeholders.
glintbooleanfalseApply enchantment glint effect.
amountstring"1"Item stack count (supports placeholders like {var:counter}).
hide_tooltipbooleanfalseHides item name and lore from hover tooltip.
hide_additional_tooltipbooleanfalseHides attributes, enchantments, and clutter.
custom_model_dataint or objectCustom model data component (supports legacy int and 1.21.4+ composite object).
item_modelstringCustom item model component ID (1.21.2+).
click_typestring"any"Which click triggers actions: any · left · right · shift
conditionobjectVisibility condition (see below).
actionsaction[][close]Actions executed in order on click. Supports "delay": int (ticks).
toggleobjectToggle definition — replaces item/actions (see below).

Placeholders

Supported in title, button name, lore, message values, and run_command values.

PlaceholderResolves to
{player}Player's display name
{gui}GUI ID (namespace:name)
{page}Current page index (0-based)
{page1}Current page index (1-based)
{pages}Total page count
{score:objective}Player's score in the given scoreboard objective
{var:key}Player's runtime variable key (empty string if unset)

Action types

Any action can be delayed by adding "delay": int (in ticks) to its JSON block.

Typevalue formatrun_withDescription
run_commandCommand stringplayer · consoleRun a command. Default: player. Supports placeholders.
closeClose the GUI.
refreshRefresh the current GUI inventory dynamically (no closing/flicker).
open_guinamespace:nameClose and open another GUI.
messageText stringSend a chat message to the player. Supports placeholders.
action_barText stringSend an action bar message directly to the player.
soundsound.id or sound.id:volume:pitchPlay a sound. Volume/pitch default to 1.0. Supports placeholders.
set_scoreobjective:valueSet player's scoreboard objective score directly (supports placeholders).
add_scoreobjective:valueAdd score to player's scoreboard objective directly.
sub_scoreobjective:valueSubtract score from player's scoreboard objective directly.
take_itemitemId:amountDeduct a specified amount of an item from the player's inventory.
add_effecteffect_id:duration:amplifier:particlesGive player status effect (duration in seconds, particles true/false).
remove_effecteffect_idRemove a specific status effect from the player.
clear_effectsClear all status effects from the player.
set_varNew valueSet a runtime variable. Requires "var": "key".
add_varInteger to addAdd an integer to a runtime variable. Requires "var": "key".
sub_varInteger to subtractSubtract an integer from a runtime variable. Requires "var": "key".
reset_varDelete a single runtime variable. Requires "var": "key".
clear_varsDelete all runtime variables for this player.
next_pageGo to the next page.
prev_pageGo to the previous page.
goto_pagePage index (string)Jump to a specific page.

Condition types

Conditions control button visibility. Hidden buttons cannot be clicked.

Typevalue formatVisible when
has_tagTag namePlayer has the scoreboard tag
not_tagTag namePlayer does not have the scoreboard tag
score_gt"objective:threshold"Player's score > threshold
score_lt"objective:threshold"Player's score < threshold
score_eq"objective:value"Player's score == value
var_eq"key:value"Runtime variable key equals value (string compare)
var_gt"key:value"Runtime variable key (int) > value
var_lt"key:value"Runtime variable key (int) < value
var_setkeyRuntime variable key is set (any value)
has_item"itemId:amount"Player has at least amount of itemId in inventory
not_item"itemId:amount"Player has less than amount of itemId in inventory
level_gtvaluePlayer's XP level > value
level_ltvaluePlayer's XP level < value
health_gtvaluePlayer's current health > value
health_ltvaluePlayer's current health < value
food_gtvaluePlayer's hunger level > value
food_ltvaluePlayer's hunger level < value

Toggle buttons

A toggle button shows different item/name/lore/actions depending on a scoreboard tag on the player. Replace the item and actions fields with a toggle object.

FieldTypeDefaultDescription
tagstring""Scoreboard tag that stores the on/off state.
item_on / item_offstringlime/gray dyeItem shown in each state.
name_on / name_offstring§aEnabled / §7DisabledDisplay name in each state.
lore_on / lore_offstring[][]Lore in each state.
glint_on / glint_offbooleanfalseGlint in each state.
actions_onaction[][tag @s remove <tag>]Actions executed on click while ON (turning OFF).
actions_offaction[][tag @s add <tag>]Actions executed on click while OFF (turning ON).

Toggle actions also fully support the multi-action engine (separated by ; in the visual editor).


Client-Side features (Optional)

Installing this mod on the client-side unlocks powerful, highly-polished user experience features:

1. In-Game GUI Editor

  • Open the Mod Menu config screen to see a list of loaded GUIs.
  • Click any GUI to open the GUI Editor Screen!
  • Visually edit GUI title, rows, tick_rate, close_on_move, and background filler.
  • Manage buttons list, add new buttons, and edit slot, item, amount, glint, lore (using ; split), multiple actions, and toggle properties.
  • Click Apply & Back to open the Gui Save Loading Screen which finds the target datapack folder on the server, safely writes the JSON to disk, and reloads the API definitions. No edits are ever lost on rejoin!

2. Native Keybindings

Integrates natively with Minecraft's official controls menu (Options > Controls > Key Binds > GUI API):

  • Accept Rules (Open GUI): Opens the default welcome GUI (Defaults to G).

Examples

Please refer to the updated example-datapack directory in the repository sources for highly-polished, fully-annotated examples demonstrating auto-refreshing clocks, direct scoreboard trading, status effect controllers, and custom visual models!


Building

chmod +x gradlew
./gradlew build
# Output: build/libs/guiapi-1.0.4.jar

Requires Java 21.


License

MIT — see LICENSE.

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

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

Minecraft: Java Edition

1.21.x

Платформы

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

Клиент и сервер

Зависимости

Ссылки

Создатели

Детали

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