mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 23:09:05 +00:00
52 lines
1.6 KiB
Java
52 lines
1.6 KiB
Java
package noppes.npcs.ai.target;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.entity.ai.EntityAITarget;
|
|
import noppes.npcs.constants.AiMutex;
|
|
import noppes.npcs.entity.EntityNPCInterface;
|
|
|
|
public class EntityAIOwnerHurtTarget extends EntityAITarget {
|
|
EntityNPCInterface npc;
|
|
EntityLivingBase theTarget;
|
|
private int field_142050_e;
|
|
|
|
public EntityAIOwnerHurtTarget(EntityNPCInterface npc) {
|
|
super(npc, false);
|
|
this.npc = npc;
|
|
this.setMutexBits(AiMutex.PASSIVE);
|
|
}
|
|
|
|
/**
|
|
* Returns whether the EntityAIBase should begin execution.
|
|
*/
|
|
public boolean shouldExecute() {
|
|
if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner())) {
|
|
return false;
|
|
} else {
|
|
EntityLivingBase entitylivingbase = this.npc.getOwner();
|
|
|
|
if (entitylivingbase == null) {
|
|
return false;
|
|
} else {
|
|
this.theTarget = entitylivingbase.getLastAttacker();
|
|
int i = entitylivingbase.getLastAttackerTime();
|
|
return i != this.field_142050_e && this.isSuitableTarget(this.theTarget, false);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Execute a one shot task or start executing a continuous task
|
|
*/
|
|
public void startExecuting() {
|
|
this.taskOwner.setAttackTarget(this.theTarget);
|
|
EntityLivingBase entitylivingbase = this.npc.getOwner();
|
|
|
|
if (entitylivingbase != null) {
|
|
this.field_142050_e = entitylivingbase.getLastAttackerTime();
|
|
}
|
|
|
|
super.startExecuting();
|
|
}
|
|
}
|