Files
netease-modsdk-wiki/docs/mcguide/20-玩法开发/15-自定义游戏内容/13-自定义物品分页.md
2025-03-17 13:24:39 +08:00

68 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
front:
hard: 入门
time: 分钟
---
# 自定义物品分页
## 概述
用于扩展原版背包分页让同一mod的自定义物品统一展示
## 注册
在 behavior 文件夹下新建 netease_tab 文件夹并在其目录下添加任意名称json 文件,例如 category_config.json配置如下
```json
{
"category":[
{
"name":"custom1", //分页名称自定义物品的json中category的值
"labelText":"itemCategory.name.custom1", //分页描述可在zh_CN.lang中设置中文名称
"icon": "textures/items/bed_green" //分页图标路径
},
{
"name":"custom2",
"labelText":"itemCategory.name.custom2",
"icon":"textures/items/apple"
}
...
]
}
```
**注name由小写字母组成请勿使用大写字母支持下划线**
效果如下图自定义分页将排列在原版分页之后分别对应custom1custom2排列在原版分页之后点击右箭头即可展示下一组分页自定义分页的顺序按照category数组顺序排列。
![image-20210727153920711](./picture/custom_category1.png)
![image-20210727154037383](./picture/custom_category2.png)
## 使用
在 behavior 文件夹下的自定义物品的 json 里,修改 `category` 值为 custom1
要在自定义分页默认显示,将 `register_to_create_menu` 设置为 true参考示例如下
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"identifier": "customblocks:test_block1",
"register_to_creative_menu": true,
"is_experimental": false,
"category":"custom1" //修改为custom1
},
"components": {
}
}
}
```
![image-20210727153819654](./picture/custom_category3.png)