属性基础修改器(ABM)允许你修改任何生物的任何属性的默认基础值。
此模组为服务端模组。
| 端 |
是否需要安装 |
| 专用服务器 |
是 |
| 集成服务器 |
是 |
| 单人游戏客户端 |
是 |
| 纯客户端 |
否 |
此模组基于数据包驱动。如果遇到任何问题,建议阅读 数据包 – Minecraft Wiki。
你可以在数据包中定义多条规则以应用修改器。
注册规则
规则通过数据包中的 JSON 文件进行注册。
规则文件应位于 data/<namespace>/abm_rules/<name>.json。
如果规则注册成功,其 ID 将为 <namespace>:<name>。
与其他数据包内容一样,当服务器重载数据时,所有规则都会重新加载。具体而言,在重载世界或使用 reload 命令时。
JSON 格式:
<root> Compound{}
include Compound{} 包含过滤器。仅包含此处指定的类型。可选,若省略则包含所有类型的生物。
type String | Array[] 需要包含的生物列表。
- String 可以是 ID 或标签(以
# 开头)。例如:minecraft:zombie、#minecraft:undead。
spawn_group String 表示包含该生成组的所有生物。必须为 monster(怪物)、creature(生物)、ambient(环境生物)、water_creature(水生生物)、underground_water_creature(地下水生生物)、water_ambient(水域环境生物)、misc(其他)或 axolotls(美西螈)之一。当与 type 共存时无效。
exclude Compound{} 排除过滤器。格式与 include 相同。可选,若省略则不排除任何生物。
modifies Array[] 定义修改方法。
- Compound{} 定义一个属性及其修改方法。如果该生物缺少此属性的默认值,将跳过此修改。
attribute String 属性 ID。例如:minecraft:max_health。
modifiers Array[] 修改方法。基础值按顺序依次计算。
- Compound{} 一种修改方法。
type String 修改类型(运算符)。必须为 set(设置)、add(添加)或 multiply(乘)之一。
value Number 此修改的值。将被解析为双精度浮点数。
default_enable Boolean 是否默认启用此规则。更多信息请参阅“调试命令”。可选,默认为 true。
示例:(某些 ID 可能不正确)
{
"include": {
"spawn_group": "monster"
},
"exclude": {
"type": "#c:bosses"
},
"modifies": [
{
"attribute": "minecraft:max_health",
"modifiers": [
{
"type": "add",
"value": 100
}
]
},
{
"attribute": "minecraft:armor",
"modifiers": [
{
"type": "set",
"value": 10
}
]
}
]
}
这是一个 example_data_pack。
调试命令
abmrule <rule_id> [enable|disable]
你可以使用此命令启用或禁用某个规则。
此命令仅用于调试。
当规则重新加载时,此状态将重置为其默认值,即规则 JSON 文件中定义的 default_enable。
常见问题
- 使用
reload 命令重新加载规则后,某些生物未发生修改。
这是预期行为。
重新加载后,之前召唤的生物可能不会更新其默认属性,除非它在代码中“被重新创建”(通常发生在生物所在区块加载时)。
然而,建议召唤一个新的生物以减少不确定性并确保它拥有最新的默认属性。
如果你希望之前召唤的生物进行更新,建议重新进入世界。
在某些情况下,例如制作整合包时,许多人会遇到这个问题。
建议通过低代码模组或 Paxi 制作全局数据包。
Attribute Base Modifier (ABM) allows you modify the default base value of any attribute of any mob.
This mod is server-side.
| Side |
Required to install |
| Dedicated server |
True |
| Integrated server |
True |
| Single-player client |
True |
| Pure client |
False |
This mod is data-driven. It's recommended to read Data pack – Minecraft Wiki if you encounter issue.
You can define multiple rules in the data pack to apply modifiers.
Register Rules
Rules are registered by JSON files in the data pack.
The rule file should be in data/<namespace>/abm_rules/<name>.json.
If the rule is successfully registered, its ID will be <namespace>:<name>.
Like other data pack contents, all rules will be reloaded when the server reloads data. Specifically, when reload the world or use reload command.
JSON format:
<root> Compound{}
include Compound{} A include filter. Only the type specified here will be included. Optional, all type of mobs will be included if omitted.
type String | Array[] List the mobs that need to be included.
- String either an ID or a tag(starts with
#). e.g. minecraft:zombie, #minecraft:undead.
spawn_group String This means all mobs of this spawn group is included. Must be one of monster, creature, ambient, water_creature, underground_water_creature, water_ambient, misc, or axolotls. Has no effect when coexists with type.
exclude Compound{} A exclude filter. The format is the same as include. Optional, no mobs will be excluded if omitted.
modifies Array[] Defines the modification methods.
- Compound{} Define an attribute and the modification methods. If the mob lacks default value of this attribute, this modification will be skipped.
attribute String ID of the attribute . e.g. minecraft:max_health.
modifiers Array[] The modification methods. The base values are calculated sequentially in order.
- Compound{} A modification method.
type String The type of modification(operator). Must be one of set, add or multiply.
value Number The value of this modification. Will be parsed as a double value.
default_enable Boolean Whether to enable this rule by default. See "Debug Command" for more information. Optional, defaults to true.
Example: (some IDs may be not correct)
{
"include": {
"spawn_group": "monster"
},
"exclude": {
"type": "#c:bosses"
},
"modifies": [
{
"attribute": "minecraft:max_health",
"modifiers": [
{
"type": "add",
"value": 100
}
]
},
{
"attribute": "minecraft:armor",
"modifiers": [
{
"type": "set",
"value": 10
}
]
}
]
}
Here is an example_data_pack.
Debug Command
abmrule <rule_id> [enable|disable]
You can enable or disable a rule by this command.
This command is for debugging.
When the rule is reloaded, this state will be reset to its default value. Specifically. the default_enable defined in the rule's JSON file.
FAQ
- Some mob is not modified after reload the rules using
reload command.
This is an expected behavior.
After a reload, a previously summoned mob may not update its default attributes unless it's "recreated" in the code (typically when mob's chunk is loaded).
However, it's recommended to summon a new mob to reduce uncertainty and ensure it has the latest default attributes.
If you want a previously summoned mob updates, it's recommended to re-enter the world.
- How to define rules before creating a world, just like a config?
In certain situations, such as when making mod packs, many people encounter this problem.
It's recommended to make a global data pack through a low-code mod or Paxi.
评论 0
登录后参与评分
还没有评论,来抢沙发吧