minecraft:behavior.nearest_prioritized_attackable_target for you with a switch.Get GodCraftOverview
minecraft:behavior.nearest_prioritized_attackable_target is an entity component: it goes in the components object of a custom mob, or in one of its component groups. Like nearest_attackable_target, but each entity type can have its own priority, so the mob prefers some targets over others. Use it when a mob should hunt players first and animals only if no player is near.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
attack_interval | integer | 0 | Seconds to wait before choosing a target. |
entity_types | EntityTypes | none | Which entities the mob may target, each with filters and a priority. |
within_radius | number | 0 | How close a target must be for the mob to go after it. |
must_see | boolean | false | If true, only targets the mob can see are picked. |
must_see_forget_duration | number | 3 | Seconds the mob keeps looking for a target that went out of sight before picking a new one. |
must_reach | boolean | false | If true, only targets the mob can walk to are picked. |
reselect_targets | boolean | false | If true, the mob switches to a closer target whenever one appears. |
scan_interval | integer | 10 | Ticks between target searches. |
target_search_height | number | -1 | How far up and down to search for targets. Use -1 to ignore height. |
persist_time | number | 0 | Seconds the mob keeps a target after it stops being valid. |
hurt_owner | boolean | false | If true, the mob also attacks mobs that hurt its owner. |
set_persistent | boolean | false | If true, the mob will not despawn after it targets a player. |
priority | integer | 0 | Decides which goal wins when several want to run: lower numbers run first.Range: 0 to … |
control_flags | Goal's control flags[] | none | Lists the body parts this goal takes control of (such as move, look or jump), so goals that need the same part don't run together. |
Example
Inside the components object of BP/entities/<name>.json (values are the defaults or placeholders):
BP/entities/<name>.json
{
"minecraft:behavior.nearest_prioritized_attackable_target": {
"attack_interval": 0,
"entity_types": {},
"within_radius": 0,
"must_see": false,
"must_see_forget_duration": 3,
"must_reach": false,
"reselect_targets": false,
"scan_interval": 10
}
}