⚔️ 装备
简介

CraftEngine 提供两种创建自定义装备的方式:基于盔甲纹饰(适用于 1.20+ 版本)或使用可装备组件(1.21.2 新增)。
请注意以下均为装备配置,非物品具体设定。要将这些配置应用到盔甲物品,请参阅此文档。
关于 3D 头盔的说明:
3D 头盔的创建方法与装备完全无关。由于许多用户在创建 3D 头盔时遇到了困难,我将在此说明正确的创建方法,并澄清一些可能存在的误解。
译者注:3D 头盔的渲染是通过渲染物品模型实现的, 而不是通过渲染盔甲模型实现的。
做个小实验尝试执行 /item replace entity @p armor.head with minecraft:glass
看看你的头上是不是渲染了一个完整的 3D 玻璃方块,尝试把 minecraft:glass
替换成 minecraft:bow
看看头上是不是渲染了一个弓物品。
但是话说回来盔甲模型的渲染优先级高于物品模型,
当使用原版头盔物品作为 material
的时候默认就会自带一个盔甲模型,
所以需要把这个盔甲模型删掉就可以渲染物品模型了,查看下面的3D 头盔原理获取解决方案。
3D 头盔原理
盔甲类物品天生带有 equippable
组件,其中包含一个名为 asset_id
的选项。当指定该选项时,Minecraft 会使用硬编码渲染器来渲染指定的盔甲纹理。这意味着即使你为基于钻石头盔的物品分配了自定义 3D 物品模型,玩家穿戴时仍会使用默认的钻石头盔盔甲渲染器进行渲染。
要解决这个问题,你必须禁用硬编码渲染器,并让头盔改用默认的物品渲染器。
解决方案1(适用于 1.21.2+ 版本):
重写 equippable
组件并移除 asset_id
选项。示例如下:
items:
default:my_3d_helemt:
material: diamond_helemt
data:
equippable:
slot: head
解决方案2(适用于1.20+版本):
使用 client-bound-material
来修改头盔在客户端的渲染方式,而不影响其服务器端功能。示例如下:
items:
default:my_3d_helemt:
material: diamond_helemt
client-bound-material: paper
基于组件
1.21.2+ 推荐equipments:
# 装备资源命名空间ID
default:topaz:
type: component
# '命名空间:路径' 解析为 assets/<命名空间>/textures/entity/equipment/<预设模型类型>/<路径>.png。
# 译者注:这里的命名空间和路径不允许使用中文
#
# 示例: minecraft:topaz
# ↓
# assets/minecraft/textures/entity/equipment/humanoid/topaz.png
humanoid: "minecraft:topaz"
# 其他预设模型类型
# assets/minecraft/textures/entity/equipment/humanoid_leggings/topaz.png
humanoid-leggings: "minecraft:topaz"
# 更多预设模型类型(根据需求添加)
# assets/minecraft/textures/entity/equipment/happy_ghast_body/topaz.png
happy-ghast-body: "minecraft:topaz"
下图展示了配置与实际纹理路径之间的映射。如果图层类型包含连字符("-"),你必须在路径中将其替换为下划线("_")。例如:humanoid-leggings
-> humanoid_leggings
。

支持的预设模型类型:
- humanoid
- humanoid-leggings
- wings
- wolf-body
- horse-body
- llama-body
- pig-saddle
- strider-saddle
- camel-saddle
- horse-saddle
- donkey-saddle
- mule-saddle
- skeleton-horse-saddle
- zombie-horse-saddle
- happy-ghast-body
❓️问: 为何 CraftEngine 不允许用户随意使用纹理路径并在生成资源包时重定位?
✔️ 答: 要求遵循 Minecraft 资源包规范——仅当 Mojang 自身违反规则时才会开放自定义路径功能,届时插件将自动处理版本适配路径。
你也可通过配置块形式设置额外选项:
equipments:
default:topaz:
type: component
humanoid:
texture: "minecraft:leather"
dyeable:
color-when-undyed: -6265536 # 皮革染色配置
# 鞘翅纹理配置
use-player-texture: false
也可通过列表组合多个纹理,以下是两个示例:
equipments:
custom:partialy_dyeable_armor:
type: component
humanoid:
- texture: "minecraft:dyeable_part"
dyeable:
color-when-undyed: -6265536
- texture: "minecraft:undyeable_part"
equipments:
custom:red_flower_wreath:
type: component
humanoid:
- texture: "minecraft:wreath"
- texture: "minecraft:red_flower"
custom:yellow_flower_wreath:
type: component
humanoid:
- texture: "minecraft:wreath"
- texture: "minecraft:yellow_flower"
custom:white_flower_wreath:
type: component
humanoid:
- texture: "minecraft:wreath"
- texture: "minecraft:white_flower"
基于盔甲纹饰
1.20+ Iris/Optifine着色器兼容 盔甲纹饰不可用当 CraftEngine 移除原版盔甲基础纹理后,装备时将呈现完全透明状态。通过对其应用自定义纹饰即可实现自定义盔甲纹理。但此方法存在一个限制——该盔甲后续无法再接受额外纹饰。
插件默认在 config.yml
中预置了原版盔甲牺牲选项,这些配置仅在您至少配置过一件基于纹饰的盔甲后才会生效。
问:被牺牲的盔甲还能正常显示吗?这是否意味着锁链甲完全不能使用了?
答:CraftEngine 预见了这种情况。解决方案出乎意料地简单(至少对 CraftEngine 而言)——我们通过应用默认纹饰图案来保持原版锁链甲外观,这依托于 CraftEngine 独有的 client-bound-data
特性实现。
# config.yml
equipment:
sacrificed-vanilla-armor:
type: chainmail
asset-id: minecraft:chainmail
humanoid: minecraft:trims/entity/humanoid/chainmail
humanoid-leggings: minecraft:trims/entity/humanoid_leggings/chainmail
# legacy_armor/configuration/chainmail.yml
items:
minecraft:chainmail_helmet:
client-bound-data:
trim:
pattern: chainmail # 用于保持原始外观的纹饰图案
material: custom
hide-tooltip:
- trim
...护腿、胸甲与靴子
此配置用于基于纹饰的盔甲套装。纹理路径无严格限制——CraftEngine将自动为您重定位纹理目录。
equipments:
# 装备资源命名空间ID
default:topaz:
type: trim
humanoid: minecraft:entity/equipment/humanoid/topaz
humanoid-leggings: minecraft:entity/equipment/humanoid_leggings/topaz
基于纹饰的盔甲仅支持 humanoid 和 humanoid-leggings 模型类型。
基于核心着色器
CraftEngine 目前不打算实现基于核心着色器的自定义盔甲。这种方法本质上会依赖皮革盔甲作为基础,这在使用第三方着色器时会失效——尽管它确实提供了纹饰兼容性。然而,考虑到截至 2025 年,超过 90% 的服务器都已运行 1.21.2+ 版本,此功能可能永远不会实现。