📐 模型
概述
指定游戏使用哪一个物品模型进行渲染,并且指定各个着色索引使用的颜色。type 默认为 minecraft:model。
items:
demo:sword:
material: diamond_sword
model:
path: minecraft:item/custom/sword
字段
| 字段 | 类型 | 必需 | 默认值 | 说明 |
|---|---|---|---|---|
type | string | 否 | minecraft:model | 模型类型标识 |
path | 资源路径 | 是* | — | 模型 JSON 的命名空间路径(如 demo:item/sword)。*设置 blueprint 时可选——此时作为生成模型的输出路径 |
generation | object | 否 | — | 从父模板自动生成模型 JSON |
blueprint | string | 否 | — | 用于转换为模型 JSON 的 Blockbench .bbmodel 文件 |
tints | list | 否 | — | 指定各个着色索引使用的颜色提供器,数组下标对应着色索引 |
transformation | object | 否 | — | 物品模型变换(26.1+) |
Blueprint(Blockbench) 实验性
blueprint 指向 blueprint 文件夹中的一个 Blockbench .bbmodel 文件(与 configuration、resourcepack 同级;路径相对于该文件夹,后缀可省略)。生成资源包时,CraftEngine 会把它转换成原版模型 JSON——几何、展示变换、GUI 光照等一并保留,省去手动从 Blockbench 导出的麻烦。
items:
demo:rocket:
material: paper
model:
blueprint: rocket # <资源文件夹>/blueprint/rocket.bbmodel
指定 path 可以控制生成的模型 JSON(以及导出的贴图)保存到哪里;不写则按 bbmodel 相对 blueprint 文件夹的路径生成到 item/ 目录下(如 furniture/rocket.bbmodel → demo:item/furniture/rocket):
items:
demo:rocket:
material: paper
model:
path: demo:furniture/rocket_v2 # → assets/demo/models/furniture/rocket_v2.json
blueprint: rocket
贴图: bbmodel 中内嵌的贴图(即在 Blockbench 里绘制的)会导出为 PNG,存放在与模型同路径的 textures 目录(demo:furniture/rocket_v2.png;多张时为 _1、_2……)。引用已有文件的贴图则保留其 命名空间:文件夹/名称 引用,不做复制。
tints 和 transformation 可与 blueprint 同用;generation 不可与其混用。
Generation
设置 generation 后,CraftEngine 自动生成模型 JSON —— 无需手动提供模型文件。只有 parent 是必填的。
items:
demo:sword:
material: diamond_sword
model:
path: demo:item/sword
generation:
parent: minecraft:item/handheld
textures:
layer0: demo:item/sword
layer1: demo:item/sword_glow
display:
thirdperson_righthand:
rotation: 0,0,0
translation: 0,1,1
scale: 0.85,0.85,0.85
gui_light: front
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
parent | 资源路径 | 是 | 继承的父模型(如 minecraft:item/generated) |
textures | map | 否 | 纹理变量覆盖(layer0、layer1 …) |
display | object | 否 | 各上下文显示变换(thirdperson_righthand、gui、ground、fixed、head、firstperson_righthand …) |
gui_light | string | 否 | GUI 光照模式:front 或 side |
Tints
items:
demo:dyeable_armor:
material: leather_chestplate
model:
path: minecraft:item/custom/armor
generation:
parent: minecraft:item/generated
textures:
layer0: minecraft:item/custom/armor
layer1: minecraft:item/custom/armor_overlay
tints:
- type: minecraft:dye
default: 16777215
指定物品模型各个着色索引使用的颜色,数组下标对应着色索引。
所有颜色值接受以下格式:
value: 16711680 # 十进制 (0x00FF0000)
value: 255,0,0 # RGB 0–255
value: 1.0,0.0,0.0 # RGB 0.0–1.0
minecraft:constant
返回固定 RGB 颜色。
tints:
- type: minecraft:constant
value: 16711680 # 红色
minecraft:dye
返回 minecraft:dyed_color 组件的值,组件不存在时使用 default。
- type: minecraft:dye
default: 16777215
minecraft:firework
返回 minecraft:firework_explosion 组件中颜色的平均值,若无颜色则使用 default。
- type: minecraft:firework
default: 16777215
minecraft:grass
根据气候采样 textures/colormap/grass.png。
- type: minecraft:grass
temperature: 0.5 # 0.0–1.0
downfall: 0.5 # 0.0–1.0
minecraft:map_color
返回 minecraft:map_color 组件的值,组件不存在时使用 default。
- type: minecraft:map_color
default: 16777215
minecraft:potion
返回 minecraft:potion_contents 组件的颜色:优先 custom_color,其次效果颜色平均值,最后 default。组件不存在时返回 default。
- type: minecraft:potion
default: 16777215
minecraft:team
返回上下文实体的队伍颜色,若无实体、无队伍或队伍无颜色时使用 default。
- type: minecraft:team
default: 16777215
minecraft:custom_model_data
读取 minecraft:custom_model_data 组件中的 colors 列表。
- type: minecraft:custom_model_data
index: 0 # colors 数组中的位置
default: 16777215