minecraft:behavior.nearest_prioritized_attackable_target
Allows the mob to check for and pursue the nearest valid target.
Properties
| Property | Type | Default | What it does |
|---|---|---|---|
attack_interval | Integer | 0 | Time in seconds before selecting a target |
entity_types | List of object or Object | [] | List of entity types that this mob considers valid targets |
filters | Object or List of object | {"AND": null, "NOT": null, "OR": null, "all": null, "all_… | Conditions that make this entry in the list valid |
max_dist | Decimal | 16 | Maximum distance this mob can be away to be a valid choice |
max_height | Decimal | -1 | Maximum height this mob can be away to be a valid choice |
max_flee | Decimal | 10 | Maximum distance this mob can be from the target to stop fleeing |
walk_speed_multiplier | Decimal | 1 | Multiplier for the walking speed. A value of 1.0 means the speed is unchanged |
sprint_speed_multiplier | Decimal | 1 | Multiplier for the sprinting speed. A value of 1.0 means the speed is unchanged |
priority | Integer | 0 | Priority for this mob type |
check_if_outnumbered | Boolean | false | If true, the mob will check if its outnumbered |
reevaluate_description | Boolean | false | If true, the mob will stop being targeted if it stops meeting any conditions. |
cooldown | Integer | 0 | The amount of time in seconds that the mob has to wait before selecting a target of the same type again |
must_see | Boolean | — | If true, the mob has to be visible to be a valid choice |
must_see_forget_duration | Integer | 3 | Determines the amount of time in seconds that this mob will look for a target before forgetting about it and looking for a new one when the target isn't visible any more |
within_radius | Decimal | 0 | Distance in blocks that the target can be within to launch an attack |
must_see | Boolean | false | If true, only entities in this mob's viewing range can be selected as targets |
must_see_forget_duration | Decimal | 3 | Determines the amount of time in seconds that this mob will look for a target before forgetting about it and looking for a new one when the target isn't visible any more |
must_reach | Boolean | false | If true, only entities that this mob can path to can be selected as targets |
reselect_targets | Boolean | false | If true, the target will change to the current closest entity whenever a different entity is closer |
scan_interval | Integer | 10 | How many ticks to wait between scanning for a target. |
target_search_height | Decimal | -1 | Height in blocks to search for a target mob. -1.0f means the height does not matter. |
persist_time | Decimal | 0 | Time in seconds for a valid target to stay targeted when it becomes an invalid target. |
hurt_owner | Boolean | false | If true, this mob will also attack mobs that hurt its owner. |
set_persistent | Boolean | false | Allows the actor to be set to persist upon targeting a player |
priority | Integermin 0 | 0 | |
control_flags | List of text | [] |
Example from the game files
This is how vanilla Fox uses it in Minecraft Bedrock 1.26.60.5:
{
"minecraft:behavior.nearest_prioritized_attackable_target": {
"priority": 6,
"attack_interval": 2,
"reselect_targets": true,
"target_search_height": 5,
"entity_types": [
{
"filters": {
"test": "is_family",
"subject": "other",
"value": "rabbit"
},
"max_dist": 12,
"priority": 0
},
{
"filters": {
"test": "is_family",
"subject": "other",
"value": "chicken"
},
"max_dist": 12,
"priority": 0
},
{
"filters": {
"test": "is_family",
"subject": "other",
"value": "cod"
},
"max_dist": 12,
"priority": 1
},
{
"filters": {
"test": "is_family",
"subject": "other",
"value": "salmon"
},
"max_dist": 12,
"priority": 1
},
{
"filters": {
"test": "is_family",
"subject": "other",
"value": "tropicalfish"
},
"max_dist": 12,
"priority": 1
},
{
"filters": {
"all_of": [
{
"test": "is_family",
"subject": "other",
"value": "baby_turtle"
},
{
"test": "in_water",
"subject": "other",
"operator": "!=",
"value": true
}
]
},
"max_dist": 12,
"priority": 0
}
]
}
}Used by 3
Vanilla entities with minecraft:behavior.nearest_prioritized_attackable_target in their definition:
Related components
behavior.nearest_attackable_targetbehavior.melee_box_attackbehavior.ranged_attackbehavior.stomp_turtle_eggbehavior.leap_at_targetbehavior.aquatic_charge_attackbehavior.charge_held_itembehavior.guardian_attackbehavior.ocelotattackbehavior.slime_attackbehavior.charge_attackbehavior.delayed_attackbehavior.dragonchargeplayerbehavior.dragonflamingbehavior.dragonstrafeplayerbehavior.fire_at_targetbehavior.knockback_roarbehavior.melee_attackbehavior.ram_attackbehavior.roarbehavior.send_eventbehavior.sonic_boombehavior.stomp_attackbehavior.summon_entity