1. Wiki
  2. /Entities
  3. /minecraft:behavior.nearest_prioritized_attackable_target

minecraft:behavior.nearest_prioritized_attackable_target

Don't want to write this by hand? GodCraft sets minecraft:behavior.nearest_prioritized_attackable_target for you with a switch.Get GodCraft

Overview

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

FieldTypeDefaultDescription
attack_intervalinteger0Seconds to wait before choosing a target.
entity_typesEntityTypesnoneWhich entities the mob may target, each with filters and a priority.
within_radiusnumber0How close a target must be for the mob to go after it.
must_seebooleanfalseIf true, only targets the mob can see are picked.
must_see_forget_durationnumber3Seconds the mob keeps looking for a target that went out of sight before picking a new one.
must_reachbooleanfalseIf true, only targets the mob can walk to are picked.
reselect_targetsbooleanfalseIf true, the mob switches to a closer target whenever one appears.
scan_intervalinteger10Ticks between target searches.
target_search_heightnumber-1How far up and down to search for targets. Use -1 to ignore height.
persist_timenumber0Seconds the mob keeps a target after it stops being valid.
hurt_ownerbooleanfalseIf true, the mob also attacks mobs that hurt its owner.
set_persistentbooleanfalseIf true, the mob will not despawn after it targets a player.
priorityinteger0Decides which goal wins when several want to run: lower numbers run first.Range: 0 to …
control_flagsGoal's control flags[]noneLists 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
  }
}

We use cookies to improve your experience and analyse site traffic. Learn more