Class AbstractEntityAIHerder<J extends AbstractJob<?,J>,B extends AbstractBuilding>
java.lang.Object
com.minecolonies.core.entity.ai.workers.AbstractAISkeleton<J>
com.minecolonies.core.entity.ai.workers.AbstractEntityAIBasic<J,B>
com.minecolonies.core.entity.ai.workers.AbstractEntityAISkill<J,B>
com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract<J,B>
com.minecolonies.core.entity.ai.workers.production.herders.AbstractEntityAIHerder<J,B>
- 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 Summary
FieldsModifier and TypeFieldDescriptionprotected static final intButchering attack damage.protected @Nullable AnimalHerdingModuleThe current herding module we're working onstatic final intLevel limit to feed children.protected static final doubleXp per action, like breed feed butcherFields inherited from class com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract
BLOCK_MINING_DELAY, RANGE_HORIZONTAL_PICKUP, RANGE_VERTICAL_PICKUP, RENDER_META_WORKING, XP_PER_BLOCKFields inherited from class com.minecolonies.core.entity.ai.workers.AbstractEntityAIBasic
building, currentWorkingLocation, needsCurrently, NO_TOOL, REQUEST_DELAY, STANDARD_DELAY, WALK_DELAY, walkTo, workPosIndexFields inherited from class com.minecolonies.core.entity.ai.workers.AbstractAISkeleton
job, worker, world -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected IAIStateBreed some animals together.protected voidbutcherAnimal(@Nullable net.minecraft.world.entity.animal.Animal animal) Butcher an animal.protected IAIStateButcher some animals (Preferably Adults and not recently fed) that the herder looks after.protected voidbutcherSwing(net.minecraftforge.common.util.FakePlayer fakePlayer, net.minecraft.world.entity.animal.Animal animal) Simulates a butcher swing against an animal.protected booleanWhether or not this one can feed adults to breed children.doublechanceToButcher(List<? extends net.minecraft.world.entity.animal.Animal> allAnimals) Returns true if animals list is above max.Decides what job the herder should switch to, breeding or Butchering.booleanequipItem(net.minecraft.world.InteractionHand hand, List<ItemStorage> itemStacks) Sets theItemStorageas held item or returns false.booleanequipTool(net.minecraft.world.InteractionHand hand, EquipmentTypeEntry toolType) Sets the tool as held item.protected IAIStateBreed some animals together.protected intCalculates after how many actions the ai should dump it's inventory.doubleGet the attack damage to be used.@NotNull List<ItemStorage>Get the extra items needed for this job.@NotNull List<EquipmentTypeEntry>Get the extra tools needed for this job.intgetItemSlot(net.minecraft.world.item.Item item) Gets the slot in which the inserted item is in.intGets an ItemStack of breedingItem for requesting, requests multiple items to decrease work for delivery manprotected static booleanisBreedAble(net.minecraft.world.entity.animal.Animal entity) Checks if we can breed this entityprotected booleanisFeedAble(net.minecraft.world.entity.animal.Animal entity) Checks if we can feed this entityprotected @NotNull List<ItemStorage>Can be overridden by implementations to specify items useful for the worker.List<? extends net.minecraft.world.entity.animal.Animal>searchForAnimals(Predicate<net.minecraft.world.entity.animal.Animal> predicate) Find animals in area.List<? extends net.minecraft.world.entity.item.ItemEntity>Find items in hut area.booleanwalkingToAnimal(net.minecraft.world.entity.animal.Animal animal) Lets the herder walk to the animal.Methods inherited from class com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract
fillItemsList, gatherItems, getBlockMiningTime, getBreakSpeedLevel, getItemsForPickUp, increaseBlockDrops, isItemWorthPickingUp, mineBlock, mineBlock, mineBlock, onBlockDropReception, resetGatheringItems, searchForItems, shouldSilkTouchBlock, triggerMinedBlockMethods inherited from class com.minecolonies.core.entity.ai.workers.AbstractEntityAIBasic
afterDump, afterRequestPickUp, cancelAsynchRequestForArmor, canGoIdle, checkAndTransferFromHut, checkForToolOrWeapon, checkForToolOrWeapon, checkForToolOrWeaponAsync, checkIfNeedsItem, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForTagExistOrCreateAsync, getBuildingToDump, getEffectiveSkillLevel, getExceptionTimer, getExpectedBuildingClass, getFakePlayer, getInventory, getInvertedEffectiveSkillLevel, getModuleForJob, getMostEfficientTool, getPrimarySkillLevel, getSecondarySkillLevel, getStateAfterPickUp, getTotalRequiredAmount, getWorkingPosition, getWorkingPosition, hasNotDelayed, holdEfficientTool, incrementActionsDone, incrementActionsDone, incrementActionsDoneAndDecSaturation, inventoryNeedsDump, isAfterDumpPickupAllowed, onException, resetActionsDone, retrieveToolInHut, retrieveToolInTileEntity, setDelay, takeItemStackFromProvider, updateRenderMetaData, waitForRequests, walkToBuilding, walkToBuilding, walkToSafePos, walkToTaggedWorkPos, walkToUnSafePos, walkToUnSafePos, walkToWorkPos, walkWithProxy, walkWithProxy, wantInventoryDumpedMethods inherited from class com.minecolonies.core.entity.ai.workers.AbstractAISkeleton
canBeInterrupted, getState, getStateAI, getTickRate, onRemoval, registerGroupTarget, registerTarget, registerTargets, resetAI, setCurrentDelay, tick
-
Field Details
-
BUTCHERING_ATTACK_DAMAGE
protected static final int BUTCHERING_ATTACK_DAMAGEButchering attack damage.- See Also:
-
LIMIT_TO_FEED_CHILDREN
public static final int LIMIT_TO_FEED_CHILDRENLevel limit to feed children.- See Also:
-
XP_PER_ACTION
protected static final double XP_PER_ACTIONXp per action, like breed feed butcher- See Also:
-
current_module
The current herding module we're working on
-
-
Constructor Details
-
AbstractEntityAIHerder
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:AbstractEntityAIBasicCalculates after how many actions the ai should dump it's inventory.Override this to change the value.
- Overrides:
getActionsDoneUntilDumpingin classAbstractEntityAIBasic<J extends AbstractJob<?,J>, B extends AbstractBuilding> - Returns:
- the number of actions done before item dump.
-
itemsNiceToHave
Description copied from class:AbstractEntityAIBasicCan 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:
itemsNiceToHavein classAbstractEntityAIBasic<J extends AbstractJob<?,J>, B extends AbstractBuilding> - Returns:
- a list with items nice to have for the worker
-
getExtraToolsNeeded
Get the extra tools needed for this job.- Returns:
- a list of tools or empty.
-
getExtraItemsNeeded
Get the extra items needed for this job.- Returns:
- a list of items needed or empty.
-
decideWhatToDo
Decides what job the herder should switch to, breeding or Butchering.- Returns:
- The next
IAIStatethe 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
Butcher some animals (Preferably Adults and not recently fed) that the herder looks after.- Returns:
- The next
IAIState.
-
breedAnimals
Breed some animals together.- Returns:
- The next
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
Streamof animals in the area.
-
getMaxAnimalMultiplier
public int getMaxAnimalMultiplier() -
searchForItemsInArea
Find items in hut area.- Returns:
- the
ListofItemEntityin 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
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
Sets the tool as held item.- Parameters:
toolType- theEquipmentTypeEntrywe want to equiphand- the hand to equip it in.- Returns:
- true if the tool was equipped.
-
equipItem
Sets theItemStorageas held item or returns false.- Parameters:
itemStacks- the list ofItemStorages 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- TheItemto 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- theFakePlayerto 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- theAnimalwe are butchering
-
getButcheringAttackDamage
public double getButcheringAttackDamage()Get the attack damage to be used.- Returns:
- the attack damage.
-
getRequestBreedingItems
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.
-