001    package net.minecraft.entity.ai;
002    
003    import net.minecraft.entity.EntityCreature;
004    import net.minecraft.util.Vec3;
005    
006    public class EntityAIWander extends EntityAIBase
007    {
008        private EntityCreature entity;
009        private double xPosition;
010        private double yPosition;
011        private double zPosition;
012        private float speed;
013    
014        public EntityAIWander(EntityCreature par1EntityCreature, float par2)
015        {
016            this.entity = 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.entity.getAge() >= 100)
027            {
028                return false;
029            }
030            else if (this.entity.getRNG().nextInt(120) != 0)
031            {
032                return false;
033            }
034            else
035            {
036                Vec3 var1 = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7);
037    
038                if (var1 == null)
039                {
040                    return false;
041                }
042                else
043                {
044                    this.xPosition = var1.xCoord;
045                    this.yPosition = var1.yCoord;
046                    this.zPosition = var1.zCoord;
047                    return true;
048                }
049            }
050        }
051    
052        /**
053         * Returns whether an in-progress EntityAIBase should continue executing
054         */
055        public boolean continueExecuting()
056        {
057            return !this.entity.getNavigator().noPath();
058        }
059    
060        /**
061         * Execute a one shot task or start executing a continuous task
062         */
063        public void startExecuting()
064        {
065            this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed);
066        }
067    }