Class AbstractEntityAIGuard<J extends AbstractJobGuard<J>,B extends AbstractBuildingGuards>
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.guard.AbstractEntityAIFight<J,B>
com.minecolonies.core.entity.ai.workers.guard.AbstractEntityAIGuard<J,B>
- 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 Summary
FieldsModifier and TypeFieldDescriptionprotected final IGuardBuildingThe guard building assigned to this job.protected static final intThe amount of time the guard counts as in combat after last combat actionprotected net.minecraft.core.BlockPosThe current blockPos we're patrolling at.protected intTimer for fighting, goes down to 0 when hasnt been fighting for a whilestatic final intHow far off patrols are alterated to match a raider attack point, sq distprotected WeakReference<EntityCitizen> The sleeping guard we foundprotected net.minecraft.world.entity.LivingEntityThe current target for our guard.protected intTimer for the wakeup AI.Fields inherited from class com.minecolonies.core.entity.ai.workers.guard.AbstractEntityAIFight
itemsNeeded, SPEED_LEVEL_BONUS, toolsNeededFields 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 TypeMethodDescriptionbooleanWhether the AI is allowed to be interruptedbooleancanHelp(net.minecraft.core.BlockPos pos) Check if we can help a citizenprotected IAIStatedecide()Decide what we should do next! Ticked once every GUARD_TASK_INTERVAL Ticksprotected intCalculates after how many actions the ai should dump it's inventory.net.minecraft.core.BlockPosGet the current patrol pointCan be overridden in implementations to return the exact building type the worker expects.getJob()Getter for the job.protected intReturns the block distance at which a guard should chase his targetvoidMovement when guardingbooleanhasTool()Check if the worker has the required tool to fight.static booleanisAttackableTarget(AbstractEntityCitizen user, net.minecraft.world.entity.LivingEntity entity) Check whether the target is attackablebooleanisWithinPersecutionDistance(net.minecraft.core.BlockPos entityPos, double attackRange) Check if a position is within the allowed persecution distance.patrol()Patrol between a list of patrol points.Patrol between all completed nodes in the assigned mineprotected net.minecraft.core.BlockPosProvides a random patrol point from all buildings in the colony when the guard is set to automatic patrol mode.voidsetWakeCitizen(EntityCitizen citizen) Set the citizen to wakeupprotected IAIStatesleep()Sleep activityvoidstartHelpCitizen(net.minecraft.world.entity.LivingEntity attacker) Assigning the guard to help a citizen.protected IAIStateRedirects the guard to their building.protected voidStops the guard from sleepingMethods inherited from class com.minecolonies.core.entity.ai.workers.guard.AbstractEntityAIFight
afterDump, afterRequestPickUp, atBuildingActions, cleanVisibleSlots, equipInventoryArmor, getStateAfterPickUpMethods 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
cancelAsynchRequestForArmor, canGoIdle, checkAndTransferFromHut, checkForToolOrWeapon, 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, getTotalRequiredAmount, getWorkingPosition, getWorkingPosition, hasNotDelayed, holdEfficientTool, incrementActionsDone, incrementActionsDone, incrementActionsDoneAndDecSaturation, inventoryNeedsDump, isAfterDumpPickupAllowed, itemsNiceToHave, 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
getState, getStateAI, getTickRate, onRemoval, registerGroupTarget, registerTarget, registerTargets, resetAI, setCurrentDelay, tick
-
Field Details
-
PATROL_DEVIATION_RAID_POINT
public static final int PATROL_DEVIATION_RAID_POINTHow far off patrols are alterated to match a raider attack point, sq dist- See Also:
-
COMBAT_TIME
protected static final int COMBAT_TIMEThe amount of time the guard counts as in combat after last combat action- See Also:
-
target
protected net.minecraft.world.entity.LivingEntity targetThe current target for our guard. -
currentPatrolPoint
protected net.minecraft.core.BlockPos currentPatrolPointThe current blockPos we're patrolling at. -
buildingGuards
The guard building assigned to this job. -
wakeTimer
protected int wakeTimerTimer for the wakeup AI. -
fighttimer
protected int fighttimerTimer for fighting, goes down to 0 when hasnt been fighting for a while -
sleepingGuard
The sleeping guard we found
-
-
Constructor Details
-
AbstractEntityAIGuard
-
-
Method Details
-
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:AbstractEntityAIBasicCalculates after how many actions the ai should dump it's inventory.Override this to change the value.
- Overrides:
getActionsDoneUntilDumpingin classAbstractEntityAIBasic<J extends AbstractJobGuard<J>,B extends AbstractBuildingGuards> - Returns:
- the number of actions done before item dump.
-
startWorkingAtOwnBuilding
Description copied from class:AbstractEntityAIFightRedirects the guard to their building.- Overrides:
startWorkingAtOwnBuildingin classAbstractEntityAIFight<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
Patrol between a list of patrol points.- Returns:
- the next patrol point to go to.
-
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
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:AbstractAISkeletonWhether the AI is allowed to be interrupted- Overrides:
canBeInterruptedin classAbstractAISkeleton<J extends AbstractJobGuard<J>>- Returns:
- true if can be interrupted
-
setWakeCitizen
Set the citizen to wakeup- Parameters:
citizen-
-
getExpectedBuildingClass
Description copied from class:AbstractEntityAIBasicCan be overridden in implementations to return the exact building type the worker expects.- Specified by:
getExpectedBuildingClassin classAbstractEntityAIBasic<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
Getter for the job.- Returns:
- the job.
-