Class MeleeCombatAI
java.lang.Object
com.minecolonies.core.entity.ai.combat.TargetAI<EntityCitizen>
com.minecolonies.core.entity.ai.combat.AttackMoveAI<EntityCitizen>
com.minecolonies.core.entity.ai.workers.guard.MeleeCombatAI
- All Implemented Interfaces:
IStateAI
- Direct Known Subclasses:
CavalryCombatAI
Knight combat AI
-
Field Summary
Fields inherited from class com.minecolonies.core.entity.ai.combat.AttackMoveAI
nextAttackTime -
Constructor Summary
ConstructorsConstructorDescriptionMeleeCombatAI(EntityCitizen owner, ITickRateStateMachine stateMachine, AbstractEntityAIGuard parentAI) -
Method Summary
Modifier and TypeMethodDescriptionprotected IAIStateCheck if the guard can protect himself with a shield And if so, do it.booleanChecks if the guard has a weapon to attack with.protected voiddoAttack(net.minecraft.world.entity.LivingEntity target) The actual attack triggered on the targetprotected doubleCalculates the damage to dealprotected intGet the delay to next attack in ticksprotected doubleGet the attack distanceprotected doubleGet combat speedprotected VisibleCitizenStatusGets the visible status of the guard when in combat.protected intThe search range in blocks, used for determining a shaped aabb entity lookupGets the weapon type that the AI will look for when checking if it can attack.protected booleanisAttackableTarget(net.minecraft.world.entity.LivingEntity entity) Whether the target is attackablebooleanCheck if is a huscarl instance.protected booleanisWithinPersecutionDistance(net.minecraft.world.entity.LivingEntity target) Check if the target is within chasing distanceprotected PathResultmoveInAttackPosition(net.minecraft.world.entity.LivingEntity target) Movement to get into attack positionprotected voidonTargetChange(net.minecraft.world.entity.LivingEntity newTarget) Actions on changing to a new target entityprotected voidonTargetDied(net.minecraft.world.entity.LivingEntity entity) When our previous target has diedprotected booleanskipSearch(net.minecraft.world.entity.LivingEntity entity) Skips the search if trueMethods inherited from class com.minecolonies.core.entity.ai.combat.AttackMoveAI
isInAttackDistance, isInDistanceForAttack, resetTarget, tryAttackMethods inherited from class com.minecolonies.core.entity.ai.combat.TargetAI
checkForTarget, getSearchArea, getYSearchRange, isEntityValidTarget, searchNearbyTarget
-
Constructor Details
-
MeleeCombatAI
public MeleeCombatAI(EntityCitizen owner, ITickRateStateMachine stateMachine, AbstractEntityAIGuard parentAI)
-
-
Method Details
-
attackProtect
Check if the guard can protect himself with a shield And if so, do it.- Returns:
- The next IAIState.
-
isHuscarl
public boolean isHuscarl()Check if is a huscarl instance.- Returns:
- true if so.
-
canAttack
public boolean canAttack()Checks if the guard has a weapon to attack with.- Overrides:
canAttackin classAttackMoveAI<EntityCitizen>- Returns:
- true if the guard can attack, false otherwise.
-
getWeaponType
Gets the weapon type that the AI will look for when checking if it can attack.- Returns:
- the weapon type.
-
doAttack
protected void doAttack(net.minecraft.world.entity.LivingEntity target) Description copied from class:AttackMoveAIThe actual attack triggered on the target- Overrides:
doAttackin classAttackMoveAI<EntityCitizen>- Parameters:
target-
-
getCombatStatus
Gets the visible status of the guard when in combat.- Returns:
- The visible status when in combat.
-
getAttackDamage
protected double getAttackDamage()Calculates the damage to deal- Returns:
- attack damage
-
getAttackDistance
protected double getAttackDistance()Description copied from class:AttackMoveAIGet the attack distance- Overrides:
getAttackDistancein classAttackMoveAI<EntityCitizen>- Returns:
- distance in blocks
-
getAttackDelay
protected int getAttackDelay()Description copied from class:AttackMoveAIGet the delay to next attack in ticks- Overrides:
getAttackDelayin classAttackMoveAI<EntityCitizen>- Returns:
- default 40 ticks
-
moveInAttackPosition
Description copied from class:AttackMoveAIMovement to get into attack position- Overrides:
moveInAttackPositionin classAttackMoveAI<EntityCitizen>- Parameters:
target- target to move towards- Returns:
- path result
-
getCombatMovementSpeed
protected double getCombatMovementSpeed()Get combat speed- Returns:
- movent speed
-
isAttackableTarget
protected boolean isAttackableTarget(net.minecraft.world.entity.LivingEntity entity) Description copied from class:TargetAIWhether the target is attackable- Overrides:
isAttackableTargetin classTargetAI<EntityCitizen>- Parameters:
entity-- Returns:
-
isWithinPersecutionDistance
protected boolean isWithinPersecutionDistance(net.minecraft.world.entity.LivingEntity target) Description copied from class:TargetAICheck if the target is within chasing distance- Overrides:
isWithinPersecutionDistancein classTargetAI<EntityCitizen>- Parameters:
target-- Returns:
-
skipSearch
protected boolean skipSearch(net.minecraft.world.entity.LivingEntity entity) Description copied from class:TargetAISkips the search if true- Overrides:
skipSearchin classTargetAI<EntityCitizen>- Parameters:
entity- checked entity- Returns:
- true if skip
-
onTargetChange
protected void onTargetChange(net.minecraft.world.entity.LivingEntity newTarget) Description copied from class:TargetAIActions on changing to a new target entity- Overrides:
onTargetChangein classTargetAI<EntityCitizen>
-
getSearchRange
protected int getSearchRange()Description copied from class:TargetAIThe search range in blocks, used for determining a shaped aabb entity lookup- Overrides:
getSearchRangein classTargetAI<EntityCitizen>- Returns:
-
onTargetDied
protected void onTargetDied(net.minecraft.world.entity.LivingEntity entity) Description copied from class:TargetAIWhen our previous target has died- Overrides:
onTargetDiedin classTargetAI<EntityCitizen>- Parameters:
entity-
-