Skip to content

自定义菜单

Craftorithm 支持通过 YAML 配置文件创建自定义菜单界面。

文件位置

plugins/Craftorithm/menus/custom/

YAML 结构

yaml
title: '&a配方列表'
layout:
  - '#########'
  - 'ABCDEFGHI'
  - '#########'
open_actions:
  - 'tell("hello world!")'
close_actions:
  - 'tell("bye bye!")'
permission: 'craftorithm.ui.recipe_list'
icons:
  '#':
    material: 'minecraft:green_stained_glass_pane'
    name: '&a边框'
  A:
    icon_type: recipe_display
    recipe_id: 'craftorithm:my_recipe'
    view_click: left
    edit_click: right

字段说明

title — 菜单标题

支持以下特殊标签:

  • <translate:lang:key> — 多语言翻译

layout — 布局网格

  • 每行字符串中的字符对应 icons 中的键
  • 空格表示该位置为空
  • 最大 6 行(54 格)

open_actions / close_actions — 脚本动作

菜单打开/关闭时执行的脚本动作列表:

yaml
open_actions:
  - 'tell("&a欢迎打开菜单")'
close_actions:
  - 'tell("&7菜单已关闭")'

permission — 权限

打开菜单所需的权限节点。

icon 配置

每个图标支持以下字段:

字段说明
material物品材质
name显示名称
lore说明文本列表
custom_model_data自定义模型数据
item_model自定义物品模型(1.21.2+)
icon_type图标类型(见下表)
recipe_id关联的配方 ID
recipe_type关联的配方类型
ingredient_slot材料槽位
view_click查看点击(left/right)
edit_click编辑点击(left/right)

icon_type 类型

类型说明
(空)普通物品图标
recipe_display配方展示图标

完整示例

yaml
title: '&6自定义配方列表'
permission: 'craftorithm.ui.my_list'
layout:
  - '#########'
  - '#ABCD EF#'
  - '#GHIJ KL#'
  - '#MNOP QR#'
  - '#########'
  - '   <N>  '
icons:
  '#':
    material: 'minecraft:gold_block'
    name: '&6边框'
  A:
    icon_type: recipe_display
    recipe_id: 'craftorithm:recipe1'
  B:
    icon_type: recipe_display
    recipe_id: 'craftorithm:recipe2'
open_actions:
  - 'tell("&6欢迎浏览配方!")'

打开自定义菜单

bash
/cra openmenu <name>
/cra openmenu <name> <player>

基于 GPL-3.0 许可证发布