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