概览
minecraft:behavior.eat_block 是一个实体组件:写在自定义生物的 components 对象中,或其中某个组件组里。 让生物吃掉一个方块并把它变成另一个方块,然后运行事件的 AI 目标,比如羊吃草后重新长毛。
字段
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
time_until_eat | number | 1.8 | 开始吃之后需要的秒数。 |
on_eat | ActorDefinitionTrigger | {"event":"","filters":{"AND":null,"NOT":null,"OR":null,"all":null,"all_of":null,"any":null,"any_of":null,"none_of":null},"target":"self"} | 生物吃完时触发的事件。 |
success_chance | Molang expression | 0.02 | 给出进食几率的 Molang 表达式。用较小的值让它很少发生。 |
eat_and_replace_block_pairs | EatAndReplaceBlockPair[] | [{"eat_block":"grass","replace_block":"dirt"},{"eat_block":"short_grass","replace_block":"air"},{"eat_block":"fern","replace_block":"air"}] | 方块对:被吃掉的方块,以及留在原处的方块。 |
priority | integer | 0 | 数字越小越先执行:两个目标冲突时,priority 更小的那个胜出。范围:0 到 … |
control_flags | Goal's control flags[] | 无 | 此目标接管哪些身体部分(移动、看向、跳跃),占用相同部分的目标不能同时运行。 |
示例
写在 BP/entities/<name>.json 的 components 对象中(值为默认值或占位值):
BP/entities/<name>.json
{
"minecraft:behavior.eat_block": {
"time_until_eat": 1.8,
"on_eat": {
"event": "",
"filters": {
"AND": null,
"NOT": null,
"OR": null,
"all": null,
"all_of": null,
"any": null,
"any_of": null,
"none_of": null
},
"target": "self"
},
"success_chance": 0.02,
"eat_and_replace_block_pairs": [
{
"eat_block": "grass",
"replace_block": "dirt"
},
{
"eat_block": "short_grass",
"replace_block": "air"
},
{
"eat_block": "fern",
"replace_block": "air"
}
],
"priority": 0,
"control_flags": []
}
}