概览
minecraft:behavior.transport_items 是一个实体组件:写在自定义生物的 components 对象中,或其中某个组件组里。 让生物把物品从一种容器搬到另一种容器,就像铜傀儡把物品从铜箱子搬进其他箱子。
字段
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
source_container_types | Block Descriptor[] | 无 | 生物从哪些容器方块中拿取物品。 |
destination_container_types | Block Descriptor[] | 无 | 生物把物品放进哪些容器方块。 |
max_stack_size | integer | 64 | 生物一次从容器中拿取的最大物品数量。范围:1 到 64 |
interaction_time | number | 3 | 生物每次在容器旁停留的秒数。范围:0 到 … |
allow_simultaneous_interaction | boolean | false | 控制容器被其他实体使用时,生物是否等待容器空出来。 |
search_strategy | enum | "random" | 生物如何选择容器:最近的,还是范围内随机的一个。可选值:nearest, random |
search_distance | Vec2 | [64,32] | 生物在水平和上下方向上寻找容器的范围。 |
max_visited_containers | integer | 16 | 生物尝试多少个容器后休息一下并重新开始。范围:0 到 … |
initial_cooldown | integer | 0 | 生物生成或获得这个目标后,开始运行前等待多久。范围:0 到 … |
idle_cooldown | integer | 20 | 找不到合适容器时目标暂停的秒数。范围:0 到 … |
place_strategy | enum | "any" | 何时把物品放进容器:只要有空间就放、只在已有相同物品时放,或在有相同物品或为空时放。可选值:any, with_matching, with_matching_or_empty |
allowed_items | Item Descriptor[] | 无 | 生物唯一可以搬运的物品。这个和 disallowed_items 都留空则允许所有物品。 |
disallowed_items | Item Descriptor[] | 无 | 生物不能搬运的物品。只能使用这个或 allowed_items 其中之一,不能同时使用。 |
priority | integer | 0 | 多个目标同时想运行时决定谁优先:数字越小越先运行。范围:0 到 … |
control_flags | Goal's control flags[] | 无 | 列出这个目标要控制的身体部分(比如移动、看向或跳跃),这样需要同一部分的目标就不会同时运行。 |
示例
写在 BP/entities/<name>.json 的 components 对象中(值为默认值或占位值):
BP/entities/<name>.json
{
"minecraft:behavior.transport_items": {
"source_container_types": [],
"destination_container_types": [],
"max_stack_size": 64,
"interaction_time": 3,
"allow_simultaneous_interaction": false,
"search_strategy": "random",
"search_distance": [
64,
32
],
"max_visited_containers": 16
}
}