AI Target Selectors
Target selectors determine what entities the mob will target for attack. They work alongside goal selectors to create intelligent mob behavior.
Usage
AITargetSelectors:
- clear # Remove vanilla targeting
- hurtby # Target whoever attacks us
- players # Target nearby players
Available Target Selectors
clear
Removes all default target selectors. Always use this first to prevent vanilla behavior from conflicting.
hurtby / hurtbytarget / attacker
Target the entity that last damaged this mob. This is reactive - the mob won't attack until provoked.
Aliases: hurtby, hurtbytarget, attacker, damager
players / player
Actively target nearby players. The mob will seek out and attack players within range.
Aliases: players, player, nearestplayer, nearestattackable, nearest
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
range | number | 16 | Detection range in blocks |
ignorelineofsight | boolean | false | If true, can target players through walls |
Example:
AITargetSelectors:
- clear
- players{range=24;ignorelineofsight=true}
monsters / monster
Target nearby hostile mobs (zombies, skeletons, etc.)
villagers / villager
Target nearby villagers
irongolem / iron_golem
Target nearby iron golems
ownerhurt
For tamed mobs: target whoever hurt the owner
ownerhurtby
For tamed mobs: target whoever the owner is attacking
animals / animal
Target nearby passive animals
nearestcreature / nearestentity
Target the nearest living entity of any type
Priority
Selectors are processed in order with auto-incrementing priority. Lower numbers = higher priority.
AITargetSelectors:
- clear
- 0 hurtby # Priority 0 (highest)
- 1 players # Priority 1
Line of Sight
By default, mobs need line of sight to target entities. If your mob isn't targeting players:
- Ensure the mob has clear view to the player
- Or add
ignorelineofsight=trueto the selector
Example Configuration
AggressiveGuard:
Type: ZOMBIE
AIGoalSelectors:
- clear
- meleeattack{speed=1.2}
- randomstroll
AITargetSelectors:
- clear
- hurtby # React when attacked
- players{range=20} # Hunt nearby players