Class AbstractEntityAIGuard<J extends AbstractJobGuard<J>,B extends AbstractBuildingGuards>

Type Parameters:
J - the generic job.
All Implemented Interfaces:
ITickingStateAI
Direct Known Subclasses:
EntityAICavalry, EntityAIDruid, EntityAIMelee, EntityAIRange

public abstract class AbstractEntityAIGuard<J extends AbstractJobGuard<J>,B extends AbstractBuildingGuards> extends AbstractEntityAIFight<J,B>
Class taking of the abstract guard methods for all fighting AIs.
  • Field Details

    • PATROL_DEVIATION_RAID_POINT

      public static final int PATROL_DEVIATION_RAID_POINT
      How far off patrols are alterated to match a raider attack point, sq dist
      See Also:
    • COMBAT_TIME

      protected static final int COMBAT_TIME
      The amount of time the guard counts as in combat after last combat action
      See Also:
    • target

      protected net.minecraft.world.entity.LivingEntity target
      The current target for our guard.
    • currentPatrolPoint

      protected net.minecraft.core.BlockPos currentPatrolPoint
      The current blockPos we're patrolling at.
    • buildingGuards

      protected final IGuardBuilding buildingGuards
      The guard building assigned to this job.
    • wakeTimer

      protected int wakeTimer
      Timer for the wakeup AI.
    • fighttimer

      protected int fighttimer
      Timer for fighting, goes down to 0 when hasnt been fighting for a while
    • sleepingGuard

      protected WeakReference<EntityCitizen> sleepingGuard
      The sleeping guard we found
  • Constructor Details

    • AbstractEntityAIGuard

      public AbstractEntityAIGuard(@NotNull J job)
  • Method Details

    • sleep

      protected IAIState sleep()
      Sleep activity
      Returns:
      the next state to go into
    • stopSleeping

      protected void stopSleeping()
      Stops the guard from sleeping
    • guardMovement

      public void guardMovement()
      Movement when guarding
    • getActionsDoneUntilDumping

      protected int getActionsDoneUntilDumping()
      Description copied from class: AbstractEntityAIBasic
      Calculates after how many actions the ai should dump it's inventory.

      Override this to change the value.

      Overrides:
      getActionsDoneUntilDumping in class AbstractEntityAIBasic<J extends AbstractJobGuard<J>,B extends AbstractBuildingGuards>
      Returns:
      the number of actions done before item dump.
    • startWorkingAtOwnBuilding

      protected IAIState startWorkingAtOwnBuilding()
      Description copied from class: AbstractEntityAIFight
      Redirects the guard to their building.
      Overrides:
      startWorkingAtOwnBuilding in class AbstractEntityAIFight<J extends AbstractJobGuard<J>,B extends AbstractBuildingGuards>
      Returns:
      The next IAIState.
    • randomPatrolPoint

      protected net.minecraft.core.BlockPos randomPatrolPoint()
      Provides a random patrol point from all buildings in the colony when the guard is set to automatic patrol mode.
      Returns:
      a BlockPos of the patrol point.
    • patrol

      public IAIState patrol()
      Patrol between a list of patrol points.
      Returns:
      the next patrol point to go to.
    • patrolMine

      public IAIState patrolMine()
      Patrol between all completed nodes in the assigned mine
      Returns:
      the next point to patrol to
    • getCurrentPatrolPoint

      public net.minecraft.core.BlockPos getCurrentPatrolPoint()
      Get the current patrol point
      Returns:
    • hasTool

      public boolean hasTool()
      Check if the worker has the required tool to fight.
      Returns:
      true if so.
    • startHelpCitizen

      public void startHelpCitizen(net.minecraft.world.entity.LivingEntity attacker)
      Assigning the guard to help a citizen.
      Parameters:
      attacker - the citizens attacker.
    • canHelp

      public boolean canHelp(net.minecraft.core.BlockPos pos)
      Check if we can help a citizen
      Parameters:
      pos -
      Returns:
      true if not fighting/helping already
    • decide

      protected IAIState decide()
      Decide what we should do next! Ticked once every GUARD_TASK_INTERVAL Ticks
      Returns:
      the next IAIState.
    • isWithinPersecutionDistance

      public boolean isWithinPersecutionDistance(net.minecraft.core.BlockPos entityPos, double attackRange)
      Check if a position is within the allowed persecution distance.
      Parameters:
      entityPos - the position to check.
      Returns:
      true if so.
    • getPersecutionDistance

      protected int getPersecutionDistance()
      Returns the block distance at which a guard should chase his target
      Returns:
      the block distance at which a guard should chase his target
    • canBeInterrupted

      public boolean canBeInterrupted()
      Description copied from class: AbstractAISkeleton
      Whether the AI is allowed to be interrupted
      Overrides:
      canBeInterrupted in class AbstractAISkeleton<J extends AbstractJobGuard<J>>
      Returns:
      true if can be interrupted
    • setWakeCitizen

      public void setWakeCitizen(EntityCitizen citizen)
      Set the citizen to wakeup
      Parameters:
      citizen -
    • getExpectedBuildingClass

      public Class<B> getExpectedBuildingClass()
      Description copied from class: AbstractEntityAIBasic
      Can be overridden in implementations to return the exact building type the worker expects.
      Specified by:
      getExpectedBuildingClass in class AbstractEntityAIBasic<J extends AbstractJobGuard<J>,B extends AbstractBuildingGuards>
      Returns:
      the building type associated with this AI's worker.
    • isAttackableTarget

      public static boolean isAttackableTarget(AbstractEntityCitizen user, net.minecraft.world.entity.LivingEntity entity)
      Check whether the target is attackable
      Parameters:
      user -
      entity -
      Returns:
    • getJob

      @NotNull public J getJob()
      Getter for the job.
      Returns:
      the job.