Class AttackMoveAI<T extends net.minecraft.world.entity.Mob & IThreatTableEntity>

java.lang.Object
com.minecolonies.core.entity.ai.combat.TargetAI<T>
com.minecolonies.core.entity.ai.combat.AttackMoveAI<T>
All Implemented Interfaces:
IStateAI
Direct Known Subclasses:
DruidCombatAI, MeleeCombatAI, RaiderMeleeAI, RaiderRangedAI, RangeCombatAI

public class AttackMoveAI<T extends net.minecraft.world.entity.Mob & IThreatTableEntity> extends TargetAI<T>
Moves the entity and triggers the attack
  • Field Details

    • nextAttackTime

      protected long nextAttackTime
      Time at which the next attack happens, worldtime + attackspeed(delay)
  • Constructor Details

  • Method Details

    • resetTarget

      public void resetTarget()
      Description copied from class: TargetAI
      Resets the current target and removes it from all saved targets.
      Overrides:
      resetTarget in class TargetAI<T extends net.minecraft.world.entity.Mob & IThreatTableEntity>
    • isInAttackDistance

      protected boolean isInAttackDistance(net.minecraft.world.entity.LivingEntity target)
      Whether the target is in attack distance
      Parameters:
      target -
      Returns:
    • tryAttack

      protected IState tryAttack()
      Check and trigger an attack
      Returns:
    • canAttack

      public boolean canAttack()
      Whether we can attack
      Returns:
    • isInDistanceForAttack

      protected boolean isInDistanceForAttack(net.minecraft.world.entity.LivingEntity target)
      Check if the target is in distance for beeing attacked
      Parameters:
      target - target to check
      Returns:
      true if we do attack
    • doAttack

      protected void doAttack(net.minecraft.world.entity.LivingEntity target)
      The actual attack triggered on the target
      Parameters:
      target -
    • getAttackDistance

      protected double getAttackDistance()
      Get the attack distance
      Returns:
      distance in blocks
    • getAttackDelay

      protected int getAttackDelay()
      Get the delay to next attack in ticks
      Returns:
      default 40 ticks
    • moveInAttackPosition

      protected PathResult moveInAttackPosition(net.minecraft.world.entity.LivingEntity target)
      Movement to get into attack position
      Parameters:
      target - target to move towards
      Returns:
      path result