    001    package net.minecraft.src;
    002
    003    import java.util.Iterator;
    004    import java.util.List;
    005
    006    public class EntityAIHurtByTarget extends EntityAITarget
    007    {
    008        boolean field_75312_a;
    009
    010        /** The PathNavigate of our entity. */
    011        EntityLiving entityPathNavigate;
    012
    013        public EntityAIHurtByTarget(EntityLiving par1EntityLiving, boolean par2)
    014        {
    015            super(par1EntityLiving, 16.0F, false);
    016            this.field_75312_a = par2;
    017            this.setMutexBits(1);
    018        }
    019
    020        /**
    021         * Returns whether the EntityAIBase should begin execution.
    022         */
    023        public boolean shouldExecute()
    024        {
    025            return this.isSuitableTarget(this.taskOwner.getAITarget(), true);
    026        }
    027
    028        /**
    029         * Returns whether an in-progress EntityAIBase should continue executing
    030         */
    031        public boolean continueExecuting()
    032        {
    033            return this.taskOwner.getAITarget() != null && this.taskOwner.getAITarget() != this.entityPathNavigate;
    034        }
    035
    036        /**
    037         * Execute a one shot task or start executing a continuous task
    038         */
    039        public void startExecuting()
    040        {
    041            this.taskOwner.setAttackTarget(this.taskOwner.getAITarget());
    042            this.entityPathNavigate = this.taskOwner.getAITarget();
    043
    044            if (this.field_75312_a)
    045            {
    046                List var1 = this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), AxisAlignedBB.getAABBPool().addOrModifyAABBInPool(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D).expand((double)this.targetDistance, 4.0D, (double)this.targetDistance));
    047                Iterator var2 = var1.iterator();
    048
    049                while (var2.hasNext())
    050                {
    051                    EntityLiving var3 = (EntityLiving)var2.next();
    052
    053                    if (this.taskOwner != var3 && var3.getAttackTarget() == null)
    054                    {
    055                        var3.setAttackTarget(this.taskOwner.getAITarget());
    056                    }
    057                }
    058            }
    059
    060            super.startExecuting();
    061        }
    062    }