    001    package net.minecraft.src;
    002
    003    public class EntityAICreeperSwell extends EntityAIBase
    004    {
    005        /** The creeper that is swelling. */
    006        EntityCreeper swellingCreeper;
    007
    008        /**
    009         * The creeper's attack target. This is used for the changing of the creeper's state.
    010         */
    011        EntityLiving creeperAttackTarget;
    012
    013        public EntityAICreeperSwell(EntityCreeper par1EntityCreeper)
    014        {
    015            this.swellingCreeper = par1EntityCreeper;
    016            this.setMutexBits(1);
    017        }
    018
    019        /**
    020         * Returns whether the EntityAIBase should begin execution.
    021         */
    022        public boolean shouldExecute()
    023        {
    024            EntityLiving var1 = this.swellingCreeper.getAttackTarget();
    025            return this.swellingCreeper.getCreeperState() > 0 || var1 != null && this.swellingCreeper.getDistanceSqToEntity(var1) < 9.0D;
    026        }
    027
    028        /**
    029         * Execute a one shot task or start executing a continuous task
    030         */
    031        public void startExecuting()
    032        {
    033            this.swellingCreeper.getNavigator().clearPathEntity();
    034            this.creeperAttackTarget = this.swellingCreeper.getAttackTarget();
    035        }
    036
    037        /**
    038         * Resets the task
    039         */
    040        public void resetTask()
    041        {
    042            this.creeperAttackTarget = null;
    043        }
    044
    045        /**
    046         * Updates the task
    047         */
    048        public void updateTask()
    049        {
    050            if (this.creeperAttackTarget == null)
    051            {
    052                this.swellingCreeper.setCreeperState(-1);
    053            }
    054            else if (this.swellingCreeper.getDistanceSqToEntity(this.creeperAttackTarget) > 49.0D)
    055            {
    056                this.swellingCreeper.setCreeperState(-1);
    057            }
    058            else if (!this.swellingCreeper.getEntitySenses().canSee(this.creeperAttackTarget))
    059            {
    060                this.swellingCreeper.setCreeperState(-1);
    061            }
    062            else
    063            {
    064                this.swellingCreeper.setCreeperState(1);
    065            }
    066        }
    067    }