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