Class AbstractEntityAIHerder<J extends AbstractJob<?,J>,B extends AbstractBuilding>

All Implemented Interfaces:
ITickingStateAI
Direct Known Subclasses:
EntityAIWorkChickenHerder, EntityAIWorkCowboy, EntityAIWorkRabbitHerder, EntityAIWorkShepherd, EntityAIWorkStablemaster, EntityAIWorkSwineHerder

public abstract class AbstractEntityAIHerder<J extends AbstractJob<?,J>,B extends AbstractBuilding> extends AbstractEntityAIInteract<J,B>
Abstract class for all Citizen Herder AIs
  • Field Details

    • BUTCHERING_ATTACK_DAMAGE

      protected static final int BUTCHERING_ATTACK_DAMAGE
      Butchering attack damage.
      See Also:
    • LIMIT_TO_FEED_CHILDREN

      public static final int LIMIT_TO_FEED_CHILDREN
      Level limit to feed children.
      See Also:
    • XP_PER_ACTION

      protected static final double XP_PER_ACTION
      Xp per action, like breed feed butcher
      See Also:
    • current_module

      @Nullable protected @Nullable AnimalHerdingModule current_module
      The current herding module we're working on
  • Constructor Details

    • AbstractEntityAIHerder

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

    • 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 AbstractJob<?,J>,B extends AbstractBuilding>
      Returns:
      the number of actions done before item dump.
    • itemsNiceToHave

      @NotNull protected @NotNull List<ItemStorage> itemsNiceToHave()
      Description copied from class: AbstractEntityAIBasic
      Can be overridden by implementations to specify items useful for the worker. When the worker inventory is full, he will try to keep these items. ItemStack amounts are ignored, the first stack found will be taken.
      Overrides:
      itemsNiceToHave in class AbstractEntityAIBasic<J extends AbstractJob<?,J>,B extends AbstractBuilding>
      Returns:
      a list with items nice to have for the worker
    • getExtraToolsNeeded

      @NotNull public @NotNull List<EquipmentTypeEntry> getExtraToolsNeeded()
      Get the extra tools needed for this job.
      Returns:
      a list of tools or empty.
    • getExtraItemsNeeded

      @NotNull public @NotNull List<ItemStorage> getExtraItemsNeeded()
      Get the extra items needed for this job.
      Returns:
      a list of items needed or empty.
    • decideWhatToDo

      public IAIState decideWhatToDo()
      Decides what job the herder should switch to, breeding or Butchering.
      Returns:
      The next IAIState the herder should switch to, after executing this method.
    • isBreedAble

      protected static boolean isBreedAble(net.minecraft.world.entity.animal.Animal entity)
      Checks if we can breed this entity
      Parameters:
      entity - to check
      Returns:
      true if breed able
    • isFeedAble

      protected boolean isFeedAble(net.minecraft.world.entity.animal.Animal entity)
      Checks if we can feed this entity
      Parameters:
      entity - to check
      Returns:
      true if feed able
    • canBreedChildren

      protected boolean canBreedChildren()
      Whether or not this one can feed adults to breed children.
      Returns:
      true if so.
    • butcherAnimals

      protected IAIState butcherAnimals()
      Butcher some animals (Preferably Adults and not recently fed) that the herder looks after.
      Returns:
      The next IAIState.
    • breedAnimals

      protected IAIState breedAnimals()
      Breed some animals together.
      Returns:
      The next IAIState.
    • feedAnimal

      protected IAIState feedAnimal()
      Breed some animals together.
      Returns:
      The next IAIState.
    • searchForAnimals

      public List<? extends net.minecraft.world.entity.animal.Animal> searchForAnimals(Predicate<net.minecraft.world.entity.animal.Animal> predicate)
      Find animals in area.
      Parameters:
      predicate - true if the animal is interesting.
      Returns:
      a Stream of animals in the area.
    • getMaxAnimalMultiplier

      public int getMaxAnimalMultiplier()
    • searchForItemsInArea

      public List<? extends net.minecraft.world.entity.item.ItemEntity> searchForItemsInArea()
      Find items in hut area.
      Returns:
      the List of ItemEntity in the area.
    • walkingToAnimal

      public boolean walkingToAnimal(net.minecraft.world.entity.animal.Animal animal)
      Lets the herder walk to the animal.
      Parameters:
      animal - the animal to walk to.
      Returns:
      true if the herder is walking to the animal.
    • chanceToButcher

      public double chanceToButcher(List<? extends net.minecraft.world.entity.animal.Animal> allAnimals)
      Returns true if animals list is above max. Returns false if animals list is within max.
      Parameters:
      allAnimals - the list of animals.
      Returns:
      chance to butcher an animal
    • equipTool

      public boolean equipTool(net.minecraft.world.InteractionHand hand, EquipmentTypeEntry toolType)
      Sets the tool as held item.
      Parameters:
      toolType - the EquipmentTypeEntry we want to equip
      hand - the hand to equip it in.
      Returns:
      true if the tool was equipped.
    • equipItem

      public boolean equipItem(net.minecraft.world.InteractionHand hand, List<ItemStorage> itemStacks)
      Sets the ItemStorage as held item or returns false.
      Parameters:
      itemStacks - the list of ItemStorages to equip one of.
      hand - the hand to equip it in.
      Returns:
      true if the item was equipped.
    • getItemSlot

      public int getItemSlot(net.minecraft.world.item.Item item)
      Gets the slot in which the inserted item is in. (if any).
      Parameters:
      item - The Item to check for.
      Returns:
      slot number -1 if not in INV.
    • butcherSwing

      protected void butcherSwing(net.minecraftforge.common.util.FakePlayer fakePlayer, net.minecraft.world.entity.animal.Animal animal)
      Simulates a butcher swing against an animal. The animal is given damage from the butcher's attack, and the butcher's held item is damaged. The swing animation is also played.
      Parameters:
      fakePlayer - the FakePlayer to simulate the attack from.
      animal - the animal being attacked.
    • butcherAnimal

      protected void butcherAnimal(@Nullable @Nullable net.minecraft.world.entity.animal.Animal animal)
      Butcher an animal.
      Parameters:
      animal - the Animal we are butchering
    • getButcheringAttackDamage

      public double getButcheringAttackDamage()
      Get the attack damage to be used.
      Returns:
      the attack damage.
    • getRequestBreedingItems

      public List<ItemStorage> getRequestBreedingItems(AnimalHerdingModule module)
      Gets an ItemStack of breedingItem for requesting, requests multiple items to decrease work for delivery man
      Parameters:
      module - the herding module.
      Returns:
      the BreedingItem stacks.