Class TargetAI<T extends net.minecraft.world.entity.Mob & IThreatTableEntity>
java.lang.Object
com.minecolonies.core.entity.ai.combat.TargetAI<T>
- All Implemented Interfaces:
IStateAI
- Direct Known Subclasses:
AttackMoveAI
public class TargetAI<T extends net.minecraft.world.entity.Mob & IThreatTableEntity>
extends Object
implements IStateAI
Target search AI
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTargetAI(T user, int targetFrequency, ITickRateStateMachine stateMachine) Constructor method for AI -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanChecks if the current targets is still valid, if not searches a new target.protected net.minecraft.world.phys.AABBGet theAABBwe're searching for targets in.protected intThe search range in blocks, used for determining a shaped aabb entity lookupprotected intGet the Y search rangeprotected booleanisAttackableTarget(net.minecraft.world.entity.LivingEntity target) Whether the target is attackablebooleanisEntityValidTarget(net.minecraft.world.entity.LivingEntity target) Checks whether the given entity is a valid target to attack.protected booleanisWithinPersecutionDistance(net.minecraft.world.entity.LivingEntity target) Check if the target is within chasing distanceprotected voidonTargetChange(net.minecraft.world.entity.LivingEntity newTarget) Actions on changing to a new target entityprotected voidonTargetDied(net.minecraft.world.entity.LivingEntity target) When our previous target has diedvoidResets the current target and removes it from all saved targets.protected booleanGet a target for the guard.protected booleanskipSearch(net.minecraft.world.entity.LivingEntity entity) Skips the search if true
-
Field Details
-
user
The entity this AI runs for -
target
protected net.minecraft.world.entity.LivingEntity targetCurrent target reference
-
-
Constructor Details
-
TargetAI
Constructor method for AI- Parameters:
user- The creature which is using the AI
-
-
Method Details
-
checkForTarget
protected boolean checkForTarget()Checks if the current targets is still valid, if not searches a new target. Adds experience if the current target died.- Returns:
- true if we found a target, false if no target.
-
isEntityValidTarget
public boolean isEntityValidTarget(net.minecraft.world.entity.LivingEntity target) Checks whether the given entity is a valid target to attack.- Parameters:
target- Entity to check- Returns:
- true if should attack
-
resetTarget
public void resetTarget()Resets the current target and removes it from all saved targets. -
searchNearbyTarget
protected boolean searchNearbyTarget()Get a target for the guard. First check if we're under attack by anything and switch target if necessary.- Returns:
- The next IAIState to go to.
-
skipSearch
protected boolean skipSearch(net.minecraft.world.entity.LivingEntity entity) Skips the search if true- Parameters:
entity- checked entity- Returns:
- true if skip
-
getSearchArea
protected net.minecraft.world.phys.AABB getSearchArea()Get theAABBwe're searching for targets in.- Returns:
- the
AABB
-
getYSearchRange
protected int getYSearchRange()Get the Y search range- Returns:
-
getSearchRange
protected int getSearchRange()The search range in blocks, used for determining a shaped aabb entity lookup- Returns:
-
isAttackableTarget
protected boolean isAttackableTarget(net.minecraft.world.entity.LivingEntity target) Whether the target is attackable- Parameters:
target-- Returns:
-
isWithinPersecutionDistance
protected boolean isWithinPersecutionDistance(net.minecraft.world.entity.LivingEntity target) Check if the target is within chasing distance- Parameters:
target-- Returns:
-
onTargetDied
protected void onTargetDied(net.minecraft.world.entity.LivingEntity target) When our previous target has died- Parameters:
target-
-
onTargetChange
protected void onTargetChange(net.minecraft.world.entity.LivingEntity newTarget) Actions on changing to a new target entity
-