Files
netease-bedrock-wiki/mcguide/20-玩法开发/15-自定义游戏内容/1-自定义物品/2-自定义武器及工具.md
2025-08-25 18:36:29 +08:00

3.0 KiB
Raw Blame History

front, hard, time
front hard time
入门 分钟

自定义武器及工具

概述

属于特殊的自定义物品,在支持自定义物品所有特性的基础上,还具有武器或工具相关的功能。

注册

  1. 与自定义基础物品的注册1-6步相同

  2. 在behavior/netease_items_beh的json中添加武器/工具相关的定义,包括:

    custom_item_type为weapon

    一个netease:weapon组件必填。组件的参数见json组件

    设置最大堆叠数量,可选

    设置耐久度,可选

avatar

{
  "format_version": "1.10",
  "minecraft:item": {
    "description": {
      "identifier": "customitems:test_sword",
      "custom_item_type": "weapon"
    },

    "components": {
      "minecraft:max_stack_size":1,
      "minecraft:max_damage":153,
      "netease:weapon":{
        "type":"sword",
        "level":3,
        "speed":8,
        "attack_damage":7,
        "enchantment":10
      }
    }
  }
}

JSON组件

description

类型 默认值 解释
category str Equipment 与普通物品不同,武器/工具的默认分类是Equipment

原版components

  • minecraft:max_stack_size

    自定义武器/工具只支持设置为1

网易components

  • netease:weapon
类型 默认值 解释
type str 武器/工具的类型,目前支持类型有:
sword
shovel
pickaxe
hatchet
hoe锄头
level int 武器/工具的level说明及修复信息下面以镐举例
1. 对于镐,对应挖掘等级
即当使用镐挖掘某些方块时,镐子的挖掘等级大于等于方块的挖掘等级,才会产生掉落物。
对于原版镐子木镐与金镐是0石镐是1铁镐是2钻石镐是3
2. 并且该值与铁砧的修复材料有关。
level为0当速度为2对应木板,否则对应金锭
level为1对应石头
level为2对应铁锭
level为3对应钻石
level大于3无法使用铁砧修复
speed int 0 对采集工具生效,表示挖掘方块时的基础速度
attack_damage int 0 攻击伤害
enchantment int 0 附魔能力。该值的解释见官方wiki

demo解释

CustomItemsMod中定义了一个自定义武器:

  • customitems:test_sword

    剑类型的自定义武器