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        EntityLiving field_75311_b;
010    
011        public EntityAIHurtByTarget(EntityLiving par1EntityLiving, boolean par2)
012        {
013            super(par1EntityLiving, 16.0F, false);
014            this.field_75312_a = par2;
015            this.setMutexBits(1);
016        }
017    
018        /**
019         * Returns whether the EntityAIBase should begin execution.
020         */
021        public boolean shouldExecute()
022        {
023            return this.isSuitableTarget(this.taskOwner.getAITarget(), true);
024        }
025    
026        /**
027         * Returns whether an in-progress EntityAIBase should continue executing
028         */
029        public boolean continueExecuting()
030        {
031            return this.taskOwner.getAITarget() != null && this.taskOwner.getAITarget() != this.field_75311_b;
032        }
033    
034        /**
035         * Execute a one shot task or start executing a continuous task
036         */
037        public void startExecuting()
038        {
039            this.taskOwner.setAttackTarget(this.taskOwner.getAITarget());
040            this.field_75311_b = this.taskOwner.getAITarget();
041    
042            if (this.field_75312_a)
043            {
044                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));
045                Iterator var2 = var1.iterator();
046    
047                while (var2.hasNext())
048                {
049                    EntityLiving var3 = (EntityLiving)var2.next();
050    
051                    if (this.taskOwner != var3 && var3.getAttackTarget() == null)
052                    {
053                        var3.setAttackTarget(this.taskOwner.getAITarget());
054                    }
055                }
056            }
057    
058            super.startExecuting();
059        }
060    }