On this page

Mob AI (Power Type)

Changes the behaviour of the mob that has the power. It can add goals such as following, fleeing or attacking, remove the mob's vanilla goals, stop it from ever targeting certain entities, and set its attack damage.

Type ID: aea:mob_ai

The power only works on mobs, not on players. Give it to a mob the same way as any other power, for example with /power grant. Everything it changed is put back when the power is removed, or while the power's condition does not hold.

Fields

FieldTypeDefaultDescription
removeString or Array of Strings[]Vanilla goals to take away from the mob. See Remove categories.
goalsArray of goals[]Goals to add.
targetsArray of target goals[]Target goals to add. These decide what the mob attacks.
never_targetBi-entity ConditionoptionalThe mob can never attack an entity that passes this condition. The actor is the mob and the target is the other entity.
attack_damageFloatoptionalSets the mob's attack damage to this value.
reapply_intervalInteger20How often, in ticks, the goals listed in remove are removed again in case the mob added them back. 0 removes them only once.

Remove categories

ValueRemoves
allEvery goal and target goal, and stops the mob's brain.
goalsEvery goal, but no target goals.
targetsEvery target goal.
brainStops the mob's brain. See the note below.
wanderWalking around at random.
look_aroundLooking around at random.
look_atLooking at players and other entities.
meleeMelee attacks.
rangedBow, crossbow and other ranged attacks.
follow_ownerA pet following its owner.
panicRunning away after being hurt.
fleeAvoiding certain entities, such as a creeper avoiding cats.
swimFloating up in water.
revengeTargeting whatever hurt the mob.

A value that contains a . is read as the Java class name of a goal, for example net.minecraft.world.entity.ai.goal.TemptGoal, and removes goals of that class. Class names written for 1.20.1 Fabric are translated for common vanilla goals.

Goals

Every goal has a type. The aea: prefix is optional, so "wander" and "aea:wander" are the same. These two fields are shared:

FieldTypeDefaultDescription
priorityIntegervariesLower numbers win when two goals want to control the mob at once. Each goal lists its default.
conditionEntity ConditionoptionalThe goal only runs while the mob passes this condition. Not used by aea:custom.

aea:wander, aea:melee_attack and aea:flee need a mob that can walk a path. They are skipped on mobs that cannot, such as slimes and ghasts.

aea:wander

Walks to random places nearby. Default priority 6.

FieldTypeDefaultDescription
speedFloat1.0Speed multiplier while walking.
intervalInteger120Average ticks between walks.
horizontal_rangeInteger10How far away, in blocks, a destination may be.
vertical_rangeInteger7How far up or down a destination may be.

aea:look_around

Looks in random directions while idle. Default priority 8. It has no fields of its own.

aea:look_at

Looks at the nearest matching entity for a few seconds. Default priority 7.

FieldTypeDefaultDescription
rangeFloat8.0How close the entity has to be.
chanceFloat0.02Chance each tick that the mob starts looking.
bientity_conditionBi-entity ConditionoptionalWhich entities the mob looks at. The actor is the mob.

aea:melee_attack

Chases the mob's current target and hits it. Default priority 2. The goal does not pick a target itself, so add a target goal as well.

FieldTypeDefaultDescription
speedFloat1.0Speed multiplier while chasing.
pause_when_idleBooleanfalseWhen true, the mob keeps the attack going after its path to the target runs out, instead of giving up.

aea:follow

Follows the mob's owner or the nearest matching entity. Default priority 4.

FieldTypeDefaultDescription
targetString"owner""owner" follows the mob's owner, if it has one. "nearest" follows the nearest matching entity.
bientity_conditionBi-entity ConditionoptionalWhich entities may be followed. The actor is the mob.
speedFloat1.0Speed multiplier while following.
start_distanceFloat6.0The mob starts following once the leader is at least this far away.
stop_distanceFloat2.5The mob stops once it is this close.
rangeFloat16.0With "nearest", how far the mob looks for someone to follow. It gives up when the leader is more than twice this far away.
teleport_distanceFloat0.0The mob teleports to the leader when it falls this far behind. 0 never teleports.

aea:flee

Runs away from the nearest matching entity. Default priority 1.

FieldTypeDefaultDescription
rangeFloat8.0How close an entity has to be for the mob to flee.
speedFloat1.0Speed multiplier while fleeing.
fast_speedFloat1.25Speed multiplier while the entity is within 7 blocks.
bientity_conditionBi-entity ConditionoptionalWhich entities the mob flees from. The actor is the mob. Without it, the mob flees from every living entity.

aea:custom

A goal built from conditions and actions. Default priority 3.

FieldTypeDefaultDescription
controlsArray of Strings[]What the goal takes over while it runs: move, look, jump or target. Two goals that use the same control cannot run at the same time.
start_conditionEntity ConditionoptionalThe goal starts when the mob passes this condition.
continue_conditionEntity ConditionoptionalThe goal keeps running while the mob passes this condition. Defaults to start_condition.
start_actionEntity ActionoptionalRuns on the mob when the goal starts.
tick_actionEntity ActionoptionalRuns on the mob while the goal is running.
stop_actionEntity ActionoptionalRuns on the mob when the goal stops.
intervalInteger1Ticks between runs of tick_action.
durationInteger0The goal stops after this many ticks. 0 means no limit.
cooldownInteger0Ticks the goal waits after stopping before it can start again.

Target goals

Target goals go in targets and share the priority and condition fields described under Goals.

aea:target

Targets the nearest matching entity. Default priority 2.

FieldTypeDefaultDescription
rangeFloatoptionalHow far the mob looks for a target. Defaults to the mob's follow range.
must_seeBooleantrueThe mob needs a line of sight to pick a target, and drops it after 3 seconds out of sight.
intervalInteger10Average ticks between searches for a target.
bientity_conditionBi-entity ConditionoptionalWhich entities may be targeted. The actor is the mob.

aea:retaliate

Targets whatever last hurt the mob. Default priority 1.

FieldTypeDefaultDescription
bientity_conditionBi-entity ConditionoptionalWhich attackers the mob fights back against. The actor is the mob.
alert_othersBooleanfalseNearby mobs of the same type that have no target join the fight.
alert_rangeFloat10.0How far away those mobs can be.

Examples

{
    "type": "aea:mob_ai",
    "remove": ["panic", "wander"],
    "attack_damage": 6,
    "goals": [
        {
            "type": "aea:melee_attack",
            "speed": 1.4
        },
        {
            "type": "aea:wander",
            "speed": 0.8
        }
    ],
    "targets": [
        {
            "type": "aea:retaliate",
            "alert_others": true
        },
        {
            "type": "aea:target",
            "range": 12,
            "bientity_condition": {
                "type": "apoli:target_condition",
                "condition": {
                    "type": "apoli:entity_type",
                    "entity_type": "minecraft:zombie"
                }
            }
        }
    ]
}

Turns a passive mob into a guard. It stops panicking, hunts zombies within 12 blocks, fights back when hurt along with others of its kind, and deals 6 damage per hit.

{
    "type": "aea:mob_ai",
    "never_target": {
        "type": "apoli:target_condition",
        "condition": {
            "type": "apoli:entity_type",
            "entity_type": "minecraft:player"
        }
    }
}

The mob keeps its vanilla behaviour but never attacks players.