Class EntityAIWorkStablemaster
java.lang.Object
com.minecolonies.core.entity.ai.workers.AbstractAISkeleton<JobStablemaster>
com.minecolonies.core.entity.ai.workers.AbstractEntityAIBasic<JobStablemaster,BuildingStable>
com.minecolonies.core.entity.ai.workers.AbstractEntityAISkill<JobStablemaster,BuildingStable>
com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract<JobStablemaster,BuildingStable>
com.minecolonies.core.entity.ai.workers.production.herders.AbstractEntityAIHerder<JobStablemaster,BuildingStable>
com.minecolonies.core.entity.ai.workers.production.herders.EntityAIWorkStablemaster
- All Implemented Interfaces:
ITickingStateAI
public class EntityAIWorkStablemaster
extends AbstractEntityAIHerder<JobStablemaster,BuildingStable>
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final floatprotected net.minecraft.world.entity.animal.horse.AbstractHorseprotected CavalryHorseEntityprotected net.minecraft.world.entity.animal.horse.AbstractHorseprotected static final intprotected static final intprotected static final doubleprotected static final intprotected static final doubleprotected intprotected static final doubleprotected intprotected List<net.minecraft.world.entity.animal.horse.AbstractHorse> Fields inherited from class com.minecolonies.core.entity.ai.workers.production.herders.AbstractEntityAIHerder
BUTCHERING_ATTACK_DAMAGE, current_module, LIMIT_TO_FEED_CHILDREN, XP_PER_ACTIONFields 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
ConstructorsConstructorDescriptionEntityAIWorkStablemaster(@NotNull JobStablemaster job) Creates the abstract part of the AI. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanattachHorse(net.minecraft.world.entity.animal.horse.AbstractHorse horse) Attempts to attach the given horse to the worker.protected IAIStateThis method is called when the AI wants to breed animals.protected booleanWhether or not the stable master should feed adults to breed children.doublechanceToButcher(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.booleancheckForToolOrWeapon(@NotNull EquipmentTypeEntry toolType) Ensures that we have a appropriate tool available.protected IAIStateConverts a normal horse into a cavalry horse.protected intCounts cavalry mounts currently assigned to this stable.Decides what the AI should do next.voiddetachHorse(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.protected voideffectsAtHorse(CavalryHorseEntity horse) Plays particles and sound effects at the given horse.static booleanfeedHorse(net.minecraft.world.entity.animal.horse.AbstractHorse horse) Feed a horseList<net.minecraft.world.entity.animal.horse.AbstractHorse> Finds all horses within 20 blocks of the given position, but outside the stable.Gather a wandering horse and bring it back to the stable with a leash.Can be overridden in implementations to return the exact building type the worker expects.@NotNull List<EquipmentTypeEntry> Get the extra tools needed for this job.booleanPrepares the AI to feed the horse.protected IAIStateWalks to the horse if already selected, and then gets it ready for combat.voidtick()Ticks the ai state.Methods inherited from class com.minecolonies.core.entity.ai.workers.production.herders.AbstractEntityAIHerder
butcherAnimal, butcherAnimals, butcherSwing, equipItem, equipTool, feedAnimal, getActionsDoneUntilDumping, getButcheringAttackDamage, getExtraItemsNeeded, getItemSlot, getMaxAnimalMultiplier, getRequestBreedingItems, isBreedAble, isFeedAble, itemsNiceToHave, searchForAnimals, searchForItemsInArea, walkingToAnimalMethods 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, checkForToolOrWeaponAsync, checkIfNeedsItem, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForTagExistOrCreateAsync, getBuildingToDump, getEffectiveSkillLevel, getExceptionTimer, 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
-
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
-
horseToRetrieve
protected net.minecraft.world.entity.animal.horse.AbstractHorse horseToRetrieve -
RECOVERY_SKILL_PAR
protected static final int RECOVERY_SKILL_PAR- See Also:
-
wanderingHorses
-
-
Constructor Details
-
EntityAIWorkStablemaster
Creates the abstract part of the AI. Always use this constructor!- Parameters:
job- the job to fulfill
-
-
Method Details
-
getExpectedBuildingClass
Description copied from class:AbstractEntityAIBasicCan be overridden in implementations to return the exact building type the worker expects.- Specified by:
getExpectedBuildingClassin classAbstractEntityAIBasic<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:
tickin interfaceITickingStateAI- Overrides:
tickin classAbstractAISkeleton<JobStablemaster>
-
getExtraToolsNeeded
Get the extra tools needed for this job.- Overrides:
getExtraToolsNeededin classAbstractEntityAIHerder<JobStablemaster,BuildingStable> - Returns:
- a list of tools or empty.
-
checkForToolOrWeapon
Ensures that we have a appropriate tool available. Will setneedsToolaccordingly. The Lead is level-less and so we need to override this here with such that a level is not checked.- Overrides:
checkForToolOrWeaponin classAbstractEntityAIBasic<JobStablemaster,BuildingStable> - Parameters:
toolType- type of tool we check for.- Returns:
- false if we have the tool
-
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:
breedAnimalsin classAbstractEntityAIHerder<JobStablemaster,BuildingStable> - Returns:
- The next
IAIState.
-
canBreedChildren
protected boolean canBreedChildren()Whether or not the stable master should feed adults to breed children.- Overrides:
canBreedChildrenin classAbstractEntityAIHerder<JobStablemaster,BuildingStable> - Returns:
- true if so.
-
chanceToButcher
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:
chanceToButcherin classAbstractEntityAIHerder<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
Decides what the AI should do next.- Overrides:
decideWhatToDoin classAbstractEntityAIHerder<JobStablemaster,BuildingStable> - Returns:
- the next state to go to.
-
convertMount
Converts a normal horse into a cavalry horse. Capacity: at most (2 × building level) CavalryHorseEntity in the herded animals. -
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
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
CavalryHorseEntityrecords registered to this building.
-
gatherMounts
Gather a wandering horse and bring it back to the stable with a leash.- Returns:
- the next state to go to.
-
effectsAtHorse
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
Finds all horses within 20 blocks of the given position, but outside the stable.- Parameters:
level- The world/level to search incenter- The center position- Returns:
- List of CavalryHorseEntity found within radius
-