Class EntityAIWorkStablemaster

All Implemented Interfaces:
ITickingStateAI

public class EntityAIWorkStablemaster extends AbstractEntityAIHerder<JobStablemaster,BuildingStable>
  • Field Details

    • TRAINING_CHANCE

      protected static final double TRAINING_CHANCE
      See Also:
    • READY_MOUNT_FOR_COMBAT_CHANCE

      protected static final double READY_MOUNT_FOR_COMBAT_CHANCE
      See Also:
    • ROUND_UP_CHANCE

      protected static final double ROUND_UP_CHANCE
      See Also:
    • BASE_COMBAT_READINESS_RECOVERY

      protected static final float BASE_COMBAT_READINESS_RECOVERY
      See Also:
    • MAX_ROUNDUP_COOLDOWN

      protected static final int MAX_ROUNDUP_COOLDOWN
      See Also:
    • roundupCooldown

      protected int roundupCooldown
    • MAX_TRAINING_COOLDOWN

      protected static final int MAX_TRAINING_COOLDOWN
      See Also:
    • trainingCooldown

      protected int trainingCooldown
    • horseToConvert

      protected net.minecraft.world.entity.animal.horse.AbstractHorse horseToConvert
    • horseToGetReady

      protected CavalryHorseEntity horseToGetReady
    • horseToRetrieve

      protected net.minecraft.world.entity.animal.horse.AbstractHorse horseToRetrieve
    • RECOVERY_SKILL_PAR

      protected static final int RECOVERY_SKILL_PAR
      See Also:
    • wanderingHorses

      protected List<net.minecraft.world.entity.animal.horse.AbstractHorse> wanderingHorses
  • Constructor Details

    • EntityAIWorkStablemaster

      public EntityAIWorkStablemaster(@NotNull @NotNull JobStablemaster job)
      Creates the abstract part of the AI. Always use this constructor!
      Parameters:
      job - the job to fulfill
  • Method Details

    • getExpectedBuildingClass

      public Class<BuildingStable> 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<JobStablemaster,BuildingStable>
      Returns:
      the building type associated with this AI's worker.
    • tick

      public void tick()
      Ticks the ai state.

      If the current state is not gathering mounts, and there is a horse to retrieve that is leashed to the worker, then the horse is unleased. This prevents the horses from being dragged to bed when the citizen sleeps...

      Specified by:
      tick in interface ITickingStateAI
      Overrides:
      tick in class AbstractAISkeleton<JobStablemaster>
    • getExtraToolsNeeded

      @NotNull public @NotNull List<EquipmentTypeEntry> getExtraToolsNeeded()
      Get the extra tools needed for this job.
      Overrides:
      getExtraToolsNeeded in class AbstractEntityAIHerder<JobStablemaster,BuildingStable>
      Returns:
      a list of tools or empty.
    • checkForToolOrWeapon

      public boolean checkForToolOrWeapon(@NotNull @NotNull EquipmentTypeEntry toolType)
      Ensures that we have a appropriate tool available. Will set needsTool accordingly. The Lead is level-less and so we need to override this here with such that a level is not checked.
      Overrides:
      checkForToolOrWeapon in class AbstractEntityAIBasic<JobStablemaster,BuildingStable>
      Parameters:
      toolType - type of tool we check for.
      Returns:
      false if we have the tool
    • breedAnimals

      protected IAIState breedAnimals()
      This method is called when the AI wants to breed animals. It sets the current status of the citizen to FIND_HORSE.

      This status is used to display the horse icon above the citizens head.

      Overrides:
      breedAnimals in class AbstractEntityAIHerder<JobStablemaster,BuildingStable>
      Returns:
      The next IAIState.
    • canBreedChildren

      protected boolean canBreedChildren()
      Whether or not the stable master should feed adults to breed children.
      Overrides:
      canBreedChildren in class AbstractEntityAIHerder<JobStablemaster,BuildingStable>
      Returns:
      true if so.
    • chanceToButcher

      public double chanceToButcher(List<? extends net.minecraft.world.entity.animal.Animal> allAnimals)
      Returns the chance to butcher an animal in the list of all animals in the building.

      The chance is calculated based on the number of animals in the building and the max allowed.

      Overrides:
      chanceToButcher in class AbstractEntityAIHerder<JobStablemaster,BuildingStable>
      Parameters:
      allAnimals - the list of all animals in the building.
      Returns:
      the chance to butcher an animal in the list of all animals in the building.
    • decideWhatToDo

      public IAIState decideWhatToDo()
      Decides what the AI should do next.
      Overrides:
      decideWhatToDo in class AbstractEntityAIHerder<JobStablemaster,BuildingStable>
      Returns:
      the next state to go to.
    • convertMount

      protected IAIState convertMount()
      Converts a normal horse into a cavalry horse. Capacity: at most (2 × building level) CavalryHorseEntity in the herded animals.
    • readyMountForCombat

      protected IAIState readyMountForCombat()
      Walks to the horse if already selected, and then gets it ready for combat. If no horse is selected, it will single-pass scan for the first horse that needs to be readied for combat.
      Returns:
      the next state to go to.
    • readyMount

      public boolean readyMount(EntityAIWorkStablemaster.MountMaintenance task, CavalryHorseEntity horse)
      Prepares the AI to feed the horse. If the worker has feed items in their inventory, it will take one of them and feed the horse. If the worker doesn't have feed items, it will request the building for one. If the building has one, it will be taken and the horse will be fed. If the building doesn't have any feed items, the AI will set a flag to indicate that it needs to request a feed item from the inventory.
    • feedHorse

      public static boolean feedHorse(net.minecraft.world.entity.animal.horse.AbstractHorse horse)
      Feed a horse
    • countCurrentMounts

      protected int countCurrentMounts()
      Counts cavalry mounts currently assigned to this stable.
      Returns:
      number of CavalryHorseEntity records registered to this building.
    • gatherMounts

      public IAIState gatherMounts()
      Gather a wandering horse and bring it back to the stable with a leash.
      Returns:
      the next state to go to.
    • effectsAtHorse

      protected void effectsAtHorse(CavalryHorseEntity horse)
      Plays particles and sound effects at the given horse.
      Parameters:
      horse - the horse to play effects at
    • attachHorse

      protected boolean attachHorse(net.minecraft.world.entity.animal.horse.AbstractHorse horse)
      Attempts to attach the given horse to the worker.
      Parameters:
      horse - the horse to attach
      Returns:
      true if the horse was successfully attached, false otherwise
    • detachHorse

      public void detachHorse(net.minecraft.world.entity.animal.horse.AbstractHorse horse)
      Detaches the given horse from the worker, removing the leash and dropping the lead item if held by the worker. If the worker is holding a lead item, it will be replaced with an empty hand.
      Parameters:
      horse - the horse to detach
    • findNearbyUnstabledHorses

      public List<net.minecraft.world.entity.animal.horse.AbstractHorse> findNearbyUnstabledHorses()
      Finds all horses within 20 blocks of the given position, but outside the stable.
      Parameters:
      level - The world/level to search in
      center - The center position
      Returns:
      List of CavalryHorseEntity found within radius