Files
CustomNPC-Plus/src/main/java/noppes/npcs/ai/target/EntityAIOwnerHurtByTarget.java
T
KAMKEEL a31efb2dc3 1.7.10 Files
Files added
2018-09-13 12:03:28 -04:00

55 lines
1.7 KiB
Java

package noppes.npcs.ai.target;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAITarget;
import net.minecraft.entity.passive.EntityTameable;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIOwnerHurtByTarget extends EntityAITarget
{
EntityNPCInterface npc;
EntityLivingBase theOwnerAttacker;
private int field_142051_e;
public EntityAIOwnerHurtByTarget(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.theOwnerAttacker = entitylivingbase.getAITarget();
int i = entitylivingbase.func_142015_aE();
return i != this.field_142051_e && this.isSuitableTarget(this.theOwnerAttacker, false);
}
}
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting(){
this.taskOwner.setAttackTarget(this.theOwnerAttacker);
EntityLivingBase entitylivingbase = this.npc.getOwner();
if (entitylivingbase != null){
this.field_142051_e = entitylivingbase.func_142015_aE();
}
super.startExecuting();
}
}