2016-08-15 17:09:01 -04:00
|
|
|
package WayofTime.bloodmagic.entity.ai;
|
|
|
|
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.ai.EntityAITarget;
|
2016-08-29 18:56:21 -04:00
|
|
|
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
2016-08-15 17:09:01 -04:00
|
|
|
|
|
|
|
public class EntityAIOwnerHurtTarget extends EntityAITarget
|
|
|
|
{
|
2016-08-29 18:56:21 -04:00
|
|
|
EntityDemonBase theEntityDemonBase;
|
2016-08-15 17:09:01 -04:00
|
|
|
EntityLivingBase theTarget;
|
|
|
|
private int timestamp;
|
|
|
|
|
2016-08-29 18:56:21 -04:00
|
|
|
public EntityAIOwnerHurtTarget(EntityDemonBase theEntityDemonBaseIn)
|
2016-08-15 17:09:01 -04:00
|
|
|
{
|
2016-08-29 18:56:21 -04:00
|
|
|
super(theEntityDemonBaseIn, false);
|
|
|
|
this.theEntityDemonBase = theEntityDemonBaseIn;
|
2016-08-15 17:09:01 -04:00
|
|
|
this.setMutexBits(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the EntityAIBase should begin execution.
|
|
|
|
*/
|
|
|
|
public boolean shouldExecute()
|
|
|
|
{
|
2016-08-29 18:56:21 -04:00
|
|
|
if (!this.theEntityDemonBase.isTamed())
|
2016-08-15 17:09:01 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
} else
|
|
|
|
{
|
2016-08-29 18:56:21 -04:00
|
|
|
EntityLivingBase entitylivingbase = this.theEntityDemonBase.getOwner();
|
2016-08-15 17:09:01 -04:00
|
|
|
|
|
|
|
if (entitylivingbase == null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
this.theTarget = entitylivingbase.getLastAttacker();
|
|
|
|
int i = entitylivingbase.getLastAttackerTime();
|
2016-08-29 18:56:21 -04:00
|
|
|
return i != this.timestamp && this.isSuitableTarget(this.theTarget, false) && this.theEntityDemonBase.shouldAttackEntity(this.theTarget, entitylivingbase);
|
2016-08-15 17:09:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute a one shot task or start executing a continuous task
|
|
|
|
*/
|
|
|
|
public void startExecuting()
|
|
|
|
{
|
|
|
|
this.taskOwner.setAttackTarget(this.theTarget);
|
2016-08-29 18:56:21 -04:00
|
|
|
EntityLivingBase entitylivingbase = this.theEntityDemonBase.getOwner();
|
2016-08-15 17:09:01 -04:00
|
|
|
|
|
|
|
if (entitylivingbase != null)
|
|
|
|
{
|
|
|
|
this.timestamp = entitylivingbase.getLastAttackerTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
super.startExecuting();
|
|
|
|
}
|
|
|
|
}
|