    001    package net.minecraft.entity.ai;
    002
    003    import net.minecraft.entity.EntityCreature;
    004    import net.minecraft.util.Vec3;
    005
    006    public class EntityAIPanic extends EntityAIBase
    007    {
    008        private EntityCreature theEntityCreature;
    009        private float speed;
    010        private double randPosX;
    011        private double randPosY;
    012        private double randPosZ;
    013
    014        public EntityAIPanic(EntityCreature par1EntityCreature, float par2)
    015        {
    016            this.theEntityCreature = par1EntityCreature;
    017            this.speed = par2;
    018            this.setMutexBits(1);
    019        }
    020
    021        /**
    022         * Returns whether the EntityAIBase should begin execution.
    023         */
    024        public boolean shouldExecute()
    025        {
    026            if (this.theEntityCreature.getAITarget() == null)
    027            {
    028                return false;
    029            }
    030            else
    031            {
    032                Vec3 var1 = RandomPositionGenerator.findRandomTarget(this.theEntityCreature, 5, 4);
    033
    034                if (var1 == null)
    035                {
    036                    return false;
    037                }
    038                else
    039                {
    040                    this.randPosX = var1.xCoord;
    041                    this.randPosY = var1.yCoord;
    042                    this.randPosZ = var1.zCoord;
    043                    return true;
    044                }
    045            }
    046        }
    047
    048        /**
    049         * Execute a one shot task or start executing a continuous task
    050         */
    051        public void startExecuting()
    052        {
    053            this.theEntityCreature.getNavigator().tryMoveToXYZ(this.randPosX, this.randPosY, this.randPosZ, this.speed);
    054        }
    055
    056        /**
    057         * Returns whether an in-progress EntityAIBase should continue executing
    058         */
    059        public boolean continueExecuting()
    060        {
    061            return !this.theEntityCreature.getNavigator().noPath();
    062        }
    063    }