Skip to content
This repository was archived by the owner on Sep 21, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 0 additions & 81 deletions .github/workflows/ci.yml

This file was deleted.

63 changes: 0 additions & 63 deletions .github/workflows/publish.yml

This file was deleted.

53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,59 @@ Minimal `config.json`:
| `confirm` | Go to a confirm page |
| `close` | Close the menu |
| `random` | Weighted random rewards |
| `link` | Clickable external URL (tellraw `open_url`) |
| `cycle` | Cycle through options (score-based selector) |

Also supports: cost, cooldown, conditions, sounds, multi-page menus, hopper/chest minecart containers.
Also supports: cost, cooldown, conditions (`item_count_*`, `score`, `has_tag`, `gamemode`, **`has_advancement`**), sounds, multi-page menus, hopper/chest minecart containers.

### New widget examples

**Link**

```json
{
"kind": "link",
"slot": 11,
"item": "minecraft:writable_book",
"name": { "text": "Discord", "color": "aqua" },
"url": "https://discord.gg/example",
"link_text": { "text": "Join our Discord", "color": "aqua" }
}
```

**Cycle**

```json
{
"kind": "cycle",
"slot": 13,
"cycle": {
"score": "difficulty",
"options": [
{ "item": "minecraft:wooden_sword", "name": { "text": "Easy", "color": "green" } },
{ "item": "minecraft:iron_sword", "name": { "text": "Normal", "color": "yellow" } },
{ "item": "minecraft:diamond_sword", "name": { "text": "Hard", "color": "red" } }
]
}
}
```

**has_advancement condition**

```json
{
"kind": "button",
"slot": 15,
"item": "minecraft:nether_star",
"name": { "text": "Claim Reward" },
"commands": ["give @s minecraft:diamond 5"],
"condition": {
"type": "has_advancement",
"advancement": "minecraft:story/mine_diamond",
"fail_message": { "text": "You need the Mine Diamond advancement!", "color": "red" }
}
}
```

---

Expand Down
14 changes: 14 additions & 0 deletions guigenmc/generators/fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from ..components import item_replace_command, mk_item_components
from ..models import (
components_for_cycle,
components_for_toggle,
container_entity_id,
container_slot_count,
Expand Down Expand Up @@ -50,6 +51,17 @@ def emit_toggle(menu: dict[str, Any], w: dict[str, Any]) -> list[str]:
return lines


def emit_cycle(menu: dict[str, Any], w: dict[str, Any]) -> list[str]:
lines: list[str] = []
opts = w["cycle"]["options"]
score = w["cycle"]["score"]
for i, _ in enumerate(opts):
item, comps = components_for_cycle(w, i)
cmd = item_replace_command(cart_selector(menu), w["slot"], item, comps)
lines.append(f"execute if score @s {score} matches {i} run {cmd}")
return lines


def emit_progress(menu: dict[str, Any], w: dict[str, Any]) -> list[str]:
lines: list[str] = []
width = w["progress_width"]
Expand Down Expand Up @@ -97,6 +109,8 @@ def generate_page_fills(menu: dict[str, Any], out: dict[str, str]) -> None:
lines.append(f"# slot {w['slot']}: {resolved_action_id(w)} ({w['kind']})")
if w["kind"] == "toggle":
lines.extend(emit_toggle(menu, w))
elif w["kind"] == "cycle":
lines.extend(emit_cycle(menu, w))
elif w["kind"] == "progress":
lines.extend(emit_progress(menu, w))
else:
Expand Down
65 changes: 65 additions & 0 deletions guigenmc/generators/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,64 @@ def handler_for(menu: dict[str, Any], w: dict[str, Any]) -> list[str]:
)
return lines

if w["kind"] == "link":
lines.extend(playsound(w.get("sound")))
url = w.get("url") or ""
link_text = w.get("link_text") or {
"text": "Click here to open",
"italic": False,
"color": "aqua",
"bold": None,
"underlined": True,
}
# Minecraft 1.21.5+: clickEvent → click_event, value → url
body = (
f'{{"text":"{escape_json(link_text.get("text") or "Open link")}",'
f'"italic":false,'
f'"color":"{link_text.get("color") or "aqua"}",'
f'"underlined":true,'
f'"click_event":{{"action":"open_url","url":"{escape_json(url)}"}}'
f'}}'
)
lines.append(
f'tellraw @s [{{"text":"[GUI-GENERATOR] ","color":"gray"}},{body}]'
)
if w.get("success_message"):
lines.append(tellraw_line(w["success_message"]))
# Keep menu open
lines.append(f"function {menu_function_prefix(menu)}/fill")
return lines

if w["kind"] == "cycle":
c = w["cycle"]
score = c["score"]
n = len(c["options"])
lines.extend(playsound(w.get("sound")))
lines.append(f"scoreboard players add @s {score} 1")
if c.get("wrap", True):
lines.append(
f"execute if score @s {score} matches {n}.. run scoreboard players set @s {score} 0"
)
else:
lines.append(
f"execute if score @s {score} matches {n}.. run scoreboard players set @s {score} {n - 1}"
)
# Run option-specific commands
for i, opt in enumerate(c["options"]):
guard = f"execute if score @s {score} matches {i} run "
for cmd in opt.get("commands") or []:
lines.append(f"{guard}{cmd}")
for fn in opt.get("functions") or []:
lines.append(f"{guard}function {fn}")
# Feedback with current option name
for i, opt in enumerate(c["options"]):
name = opt.get("name") or {"text": f"Option {i}", "color": "yellow"}
lines.append(
f"execute if score @s {score} matches {i} run {tellraw_line(name)}"
)
lines.append(f"function {menu_function_prefix(menu)}/fill")
return lines

if w.get("condition") is not None:
cond = w["condition"]
fail = cond.get("fail_message") or {
Expand Down Expand Up @@ -271,6 +329,13 @@ def success_block(prefix: str) -> list[str]:
lines.append(
f"execute unless entity @s[gamemode={cond['gamemode']}] run {tellraw_line(fail)}"
)
elif cond["type"] == "has_advancement":
adv = cond.get("advancement") or ""
ok = f"execute if entity @s[advancements={{{adv}=true}}] run "
lines.extend(success_block(ok))
lines.append(
f"execute unless entity @s[advancements={{{adv}=true}}] run {tellraw_line(fail)}"
)
else:
lines.extend(emit_actions(w))
if w.get("success_message"):
Expand Down
2 changes: 2 additions & 0 deletions guigenmc/generators/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def generate_open(menu: dict[str, Any], out: dict[str, str]) -> None:
scores_to_init.append(w["counter_score"])
if w.get("progress_score"):
scores_to_init.append(w["progress_score"])
if w.get("cycle"):
scores_to_init.append(w["cycle"]["score"])
for sc in scores_to_init:
if sc in inited:
continue
Expand Down
Loading