AI
Overview
Groups
Example
package demo.entity;
import net.minestom.server.entity.ai.EntityAIGroupBuilder;
import net.minestom.server.entity.ai.goal.RandomLookAroundGoal;
import net.minestom.server.entity.type.monster.EntityZombie;
import net.minestom.server.entity.EntityType;
public class ZombieCreature extends EntityCreature {
public ZombieCreature() {
super(EntityType.ZOMBIE);
addAIGroup(
List.of(
new MeleeAttackGoal(this, 1.6, 20, TimeUnit.SERVER_TICK), // Attack the target
new RandomStrollGoal(this, 20) // Walk around
)
List.of(
new LastEntityDamagerTarget(this, 32), // First target the last entity which attacked you
new ClosestEntityTarget(this, 32, entity -> entity instanceof Player) // If there is none, target the nearest player
)
);
}
}Last updated
Was this helpful?
