附魔 ID 配置

基本信息

属性 值
配置分类 EnchantmentsID
配置项数 7
读取位置 BattlegearConfig.registerRecipes(BattlegearConfig.java:310-321)
触发时机 init 阶段(Battlegear.java:83)
需要重启 是,全部 setRequiresMcRestart(true)

功能

7 个自定义附魔的 id 全部可配置。分类注释说明合法范围:

"Values should be between 0 and " + (Enchantment.enchantmentsList.length - 1)
        + ", or the enchantment will be disabled"

(BattlegearConfig.java:311-313)

冲突自动顺延

配置值只作为搜索起点。EnchantmentHelper.takeNextAvailableId(Property) 会:

  1. 读取配置中的 int 值作为起点
  2. 起点须在 0 ~ Enchantment.enchantmentsList.length 之间,否则返回 INVALID(-1)
  3. 从起点向上找到第一个已被其他附魔占用的 id 之前的位置;若该位置已在内部 BitSet 预留中,则继续向上
  4. 找到后写回配置 property.set(result)

来源:EnchantmentHelper.java:147-157(Property 版本)、:120-138(带预留的搜索)、:104-111(查找下一个可用 id)。

最小可用 id 下限为 MIN_FREE_SLOT = 8(EnchantmentHelper.java:39, 105)。

因此手工填写的 id 未必是最终生效的 id —— 与其他附魔冲突时会被自动改写并保存(BattlegearConfig.java:319-321)。填入越界或负数则该附魔完全不注册,Optional.absent(),后续所有效果判定都会因 isPresent() 为 false 而跳过。

数值

默认 id 按数组顺序递增,起始 125(BattlegearConfig.java:314-317):

props[i] = file.get("EnchantmentsID", enchantsName[i], 125 + i).setRequiresMcRestart(true);
附魔 配置键 默认 id 键顺序来源
Bash Weightless BashWeight 125 BattlegearConfig.java:67-68, 315-317
Bash Power BashPower 126 同上
Bash Damage BashDamage 127 同上
Shield Usage ShieldUsage 128 同上
Shield Recovery ShieldRecovery 129 同上
Bow Loot BowLoot 130 同上
Bow Charge BowCharge 131 同上

默认 id 125 ~ 131 是配置文件中声明的起始值(BattlegearConfig.java:316)。实际运行时的最终 id 取决于与整合包中其他附魔的冲突情况,可能被自动顺延,无法从本仓库静态确定。

注册本身由 BaseEnchantment.initBase(props) 完成,参数顺序与 props 数组一一对应(BattlegearConfig.java:318、BaseEnchantment.java:78-88)。

交互

触发 行为
正常启动 7 个附魔依次注册,起始 id 125 起;冲突则顺延
配置值越界或为负 该附魔 Optional.absent(),完全不注册
某个附魔被移除 其后附魔的 id 会被回填(顺延逻辑的结果)
读入完成 file.hasChanged() 为真时保存配置(BattlegearConfig.java:319-321)

注册失败时 EnchantmentHelper.build 会捕获异常并记 FMLLog 错误日志 Caught an exception during enchantment registration(EnchantmentHelper.java:188-190),随后返回 Optional.absent()。

合成配方

不适用。

相关条目