001    package net.minecraft.src;
002    
003    public class EntityAIDefendVillage extends EntityAITarget
004    {
005        EntityIronGolem irongolem;
006    
007        /**
008         * The aggressor of the iron golem's village which is now the golem's attack target.
009         */
010        EntityLiving villageAgressorTarget;
011    
012        public EntityAIDefendVillage(EntityIronGolem par1EntityIronGolem)
013        {
014            super(par1EntityIronGolem, 16.0F, false, true);
015            this.irongolem = par1EntityIronGolem;
016            this.setMutexBits(1);
017        }
018    
019        /**
020         * Returns whether the EntityAIBase should begin execution.
021         */
022        public boolean shouldExecute()
023        {
024            Village var1 = this.irongolem.getVillage();
025    
026            if (var1 == null)
027            {
028                return false;
029            }
030            else
031            {
032                this.villageAgressorTarget = var1.findNearestVillageAggressor(this.irongolem);
033                return this.isSuitableTarget(this.villageAgressorTarget, false);
034            }
035        }
036    
037        /**
038         * Execute a one shot task or start executing a continuous task
039         */
040        public void startExecuting()
041        {
042            this.irongolem.setAttackTarget(this.villageAgressorTarget);
043            super.startExecuting();
044        }
045    }