mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 12:19:59 +00:00
55 lines
1.7 KiB
Java
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();
|
|
}
|
|
} |