跳转到内容

数据包注册

通过数据包 JSON 注册内容,与 Java API 注册等价、共享同一注册表。/reload 可热重载 JSON 定义。

通用规则

  • JSON 文件放在 data/<命名空间>/modularshoot/<注册表路径>/<id>.json
  • 文件名为条目 ID(不含命名空间),命名空间由文件夹路径决定
  • 所有资源路径字段使用完整命名空间格式(如 modularshoot:textures/gun/rifle.png
  • 可选字段省略时使用代码中注明的默认值
  • /reload 后 JSON 定义即时生效,已发放物品的行为实时跟随新定义

枪械 JSON

路径data/<命名空间>/modularshoot/guns/<枪械id>.json

JSON 键类型必需默认值说明
name字符串无(回退到枪械 ID 路径部分)显示名称,支持 § 颜色代码和 lang: 翻译键前缀
texture资源路径字符串基础纹理路径(如 "modularshoot:textures/gun/rifle.png"
shoot_texture资源路径字符串射击纹理路径。不指定时射击期间始终使用基础纹理
shoot_texture_mode字符串"per_shot"射击纹理切换模式。"per_shot"(每次射击切纹理)/ "while_firing"(按住射击期间持续显示)。仅在指定了 shoot_texture 时生效
stats属性ID→浮点数对象{}属性基础值。键必须带完整命名空间(如 "modularshoot:hit_damage": 50.0)。不出现的属性使用元数据表默认值
traits特性ID→布尔值对象{}枪械固有特性覆盖。无特性时留空对象 {}
slots种类ID→整数对象{}插件插槽配置,键为插件种类 ID,值为插槽数量
sounds字符串→资源路径对象{}音效绑定。如 "shoot": "modularshoot:gun.rifle.shoot"
bullet_style对象子弹视觉样式(见下表)

bullet_style 子字段

JSON 键类型必需默认值说明
model字符串→资源路径对象渲染资源。"3d"→模型路径,"billboard"→纹理路径。建议两者都提供
render_mode字符串"billboard"(2D 精灵)或 "3d"(静态 3D 模型)

路径data/examplemod/modularshoot/guns/assault_rifle.json

json
{
  "name": "§a突击步枪",
  "texture": "examplemod:textures/gun/assault_rifle.png",
  "shoot_texture": "examplemod:textures/gun/assault_rifle_shoot.png",
  "shoot_texture_mode": "while_firing",
  "stats": {
    "modularshoot:hit_damage": 8.0,
    "modularshoot:fire_rate": 10.0,
    "modularshoot:range": 60.0,
    "modularshoot:accuracy_yaw": 3.0,
    "modularshoot:accuracy_pitch": 3.5,
    "modularshoot:entity_penetration": 0,
    "modularshoot:bullet_speed": 50.0,
    "modularshoot:bullet_size": 0.2,
    "modularshoot:block_penetration": 0
  },
  "traits": {
    "examplemod:full_auto": true
  },
  "slots": {
    "examplemod:barrel": 1,
    "examplemod:magazine": 1,
    "examplemod:grip": 1
  },
  "sounds": {
    "shoot": "examplemod:gun.assault_rifle.shoot"
  },
  "bullet_style": {
    "model": {
      "3d": "examplemod:models/bullet/rifle_bullet.json",
      "billboard": "examplemod:textures/bullet/rifle_bullet.png"
    },
    "render_mode": "billboard"
  }
}

插件 JSON

路径data/<命名空间>/modularshoot/plugins/<插件id>.json

JSON 键类型必需默认值说明
name字符串显示名称,支持 § 颜色代码
tags字符串数组[]匹配用标签列表(如 ["c:barrel", "examplemod:barrel"])。空数组时无法匹配任何种类
priority整数0特性冲突优先级,越大越优先
item_icon资源路径字符串物品图标纹理路径
modifiers对象数组[]属性修饰符列表(见下表)
traits特性ID→布尔值对象{}安装后提供的特性覆盖
exclusive_group字符串互斥组 ID。同一枪上同组插件不可共存
bullet_style对象子弹样式覆盖(格式同枪械的 bullet_style)。整体覆盖非字段级合并
texture_overlay对象纹理叠加(见下表)
brief字符串一行简介
description字符串多行详细描述
color字符串名称颜色(如 "#FF4444"

modifiers 子字段

JSON 键类型必需默认值说明
attribute字符串目标属性名。不带命名空间时默认 modularshoot 命名空间(如 "fire_rate"modularshoot:fire_rate
operation字符串"add"(加算)/ "multiply"(普通乘算)/ "multiply_total"(最终乘算)
value浮点数修饰数值

texture_overlay 子字段

JSON 键类型必需默认值说明
texture资源路径字符串叠加图层纹理路径
layer整数层级,越大越靠上。同层级按安装顺序(后装覆盖先装)

路径data/examplemod/modularshoot/plugins/rapid_barrel.json

json
{
  "name": "§c速射枪管",
  "tags": ["c:barrel", "examplemod:barrel"],
  "priority": 150,
  "item_icon": "examplemod:textures/plugins/rapid_barrel.png",
  "modifiers": [
    { "attribute": "fire_rate", "operation": "multiply", "value": 1.0 },
    { "attribute": "hit_damage", "operation": "multiply", "value": -0.2 },
    { "attribute": "accuracy_yaw", "operation": "multiply_total", "value": 0.3 }
  ],
  "traits": { "examplemod:rapid_fire": true },
  "exclusive_group": "group:barrel_type",
  "bullet_style": {
    "model": { "billboard": "examplemod:textures/bullet/fast_bullet.png" },
    "render_mode": "billboard"
  },
  "texture_overlay": {
    "texture": "examplemod:textures/plugins/rapid_barrel_overlay.png",
    "layer": 10
  },
  "brief": "大幅提升射速,但伤害和精准度略有下降",
  "description": "安装后射速翻倍,但单发伤害降低 20%,散布增加 30%。",
  "color": "#FF4444"
}

路径data/examplemod/modularshoot/plugins/extended_mag.json

json
{
  "name": "§b扩容弹匣",
  "tags": ["c:magazine", "examplemod:magazine"],
  "priority": 100,
  "item_icon": "examplemod:textures/plugins/extended_mag.png",
  "modifiers": [
    { "attribute": "fire_rate", "operation": "add", "value": 2.0 }
  ],
  "exclusive_group": "group:mag_type",
  "brief": "增加弹容量",
  "color": "#44AAFF"
}

插件种类 JSON

路径data/<命名空间>/modularshoot/plugin_types/<种类id>.json

JSON 键类型必需默认值说明
name字符串种类显示名称
tags字符串数组[]匹配用标签列表。空数组时无法匹配任何插件
priority整数0显示优先级 + 安装自动选择二级排序键。不影响插件特性冲突优先级
color字符串种类名称颜色(如 "#FFAA00"

路径data/examplemod/modularshoot/plugin_types/barrel.json

json
{
  "name": "枪管",
  "tags": ["c:barrel", "examplemod:barrel"],
  "priority": 10,
  "color": "#FFAA00"
}

路径data/examplemod/modularshoot/plugin_types/grip.json

json
{
  "name": "握把",
  "tags": ["c:grip", "examplemod:grip"],
  "priority": 30,
  "color": "#8888FF"
}

特性 JSON

路径data/<命名空间>/modularshoot/traits/<特性id>.json

JSON 键类型必需默认值说明
default_value布尔值默认值。枪械未声明该特性时使用
name字符串无(回退到特性 ID 路径部分)显示名称,支持 §lang:
description字符串""说明文本
color字符串名称颜色(如 "#FF8800"
brief字符串一行简介
force_show布尔值false是否强制展示(无论值为何都显示在 tooltip)
priority整数0显示优先级,越大越靠前

路径data/examplemod/modularshoot/traits/ignite.json

json
{
  "default_value": false,
  "name": "子弹着火",
  "description": "命中时点燃目标",
  "color": "#FF8800",
  "brief": "命中时点燃目标 3 秒",
  "force_show": false,
  "priority": 10
}

属性元数据 JSON

路径data/<命名空间>/modularshoot/attribute_meta/<属性逻辑id>.json

此表只登记元数据,不创建属性本体。属性本体须用原版 DeferredRegister 注册。

JSON 键类型必需默认值说明
binds资源路径字符串指向已注册的原版 Attribute ID(如 "minecraft:generic.max_health")。框架通过此字段定位 Attribute holder
default_value浮点数枪械未声明该属性时的基础值(参与加算)。非原版 base 值
description字符串""说明文本
color字符串""名称颜色
priority整数0显示优先级
force_show布尔值false是否强制展示

路径data/examplemod/modularshoot/attribute_meta/custom_recoil.json

json
{
  "binds": "examplemod:custom_recoil",
  "default_value": 5.0,
  "description": "自定义后坐力属性",
  "color": "#FF9944",
  "priority": 15,
  "force_show": true
}

路径data/examplemod/modularshoot/attribute_meta/hit_damage.json

(覆盖框架预置属性的元数据——调整默认值和颜色)

json
{
  "binds": "modularshoot:hit_damage",
  "default_value": 2.0,
  "color": "#FF2222",
  "priority": 0,
  "force_show": false
}

状态 JSON

路径data/<命名空间>/modularshoot/states/<状态id>.json

JSON 键类型必需默认值说明
domain字符串归属域。"gun" / "player" / "bullet"
value_type字符串值类型。"int" / "long" / "double" / "float" / "boolean" / "string" / "uuid"
default_value对应类型对应类型零值初始值,类型须与 value_type 匹配
display对象显示元数据(见下表)

display 子字段

JSON 键类型必需默认值说明
name字符串tooltip 中状态名称。支持 §lang:
color字符串""名称颜色(如 "#FFAA00")。可选,省略时使用默认 tooltip 颜色
format字符串"{value}"显示模板,{value} 占位
priority整数0显示排序,越大越靠前
hide_default布尔值false值为默认值时不显示

路径data/examplemod/modularshoot/states/kill_count.json

json
{
  "domain": "gun",
  "value_type": "int",
  "default_value": 0,
  "display": {
    "name": "击杀层数",
    "color": "#FFAA00",
    "format": "{value} 层",
    "priority": 10,
    "hide_default": true
  }
}

路径data/examplemod/modularshoot/states/heat.json

json
{
  "domain": "gun",
  "value_type": "double",
  "default_value": 0.0,
  "display": {
    "name": "热量",
    "color": "#FF4400",
    "format": "{value} °C",
    "priority": 5,
    "hide_default": false
  }
}

路径data/examplemod/modularshoot/states/headshot_streak.json

json
{
  "domain": "player",
  "value_type": "int",
  "default_value": 0,
  "display": {
    "name": "连续爆头",
    "color": "#FFD700",
    "format": "{value} 连杀",
    "priority": 20,
    "hide_default": true
  }
}

路径data/examplemod/modularshoot/states/target_entity.json

json
{
  "domain": "bullet",
  "value_type": "uuid",
  "display": {
    "name": "锁定目标",
    "color": "#AA44FF",
    "priority": 0,
    "hide_default": true
  }
}

注册冲突与覆盖

场景行为
同一 ID 同时存在于 Java API 和数据包Java API 优先,数据包注册被忽略,日志输出警告
同一 ID 出现在多个数据包中数据包加载顺序靠后的覆盖靠前(遵循 pack.mcmeta 优先级)
Java API 注册后通过数据包覆盖不支持。需在 Java 代码中通过 API 修改

/reload 重载行为

  • 重载后 JSON 定义即时更新,已发放物品的行为实时跟随新定义(因为始终从注册表实时读取)
  • 物品上的 Data Component 字段(gunIdpluginId 等)不随 /reload 改变
  • Java API 注册的条目不受 /reload 影响(不丢失)
  • 创造模式标签页在重载后自动刷新

基于 MIT 许可发布