    001    package net.minecraft.src;
    002
    003    public class EntityAIMoveTwardsRestriction extends EntityAIBase
    004    {
    005        private EntityCreature theEntity;
    006        private double movePosX;
    007        private double movePosY;
    008        private double movePosZ;
    009        private float movementSpeed;
    010
    011        public EntityAIMoveTwardsRestriction(EntityCreature par1EntityCreature, float par2)
    012        {
    013            this.theEntity = par1EntityCreature;
    014            this.movementSpeed = 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.theEntity.isWithinHomeDistanceCurrentPosition())
    024            {
    025                return false;
    026            }
    027            else
    028            {
    029                ChunkCoordinates var1 = this.theEntity.getHomePosition();
    030                Vec3 var2 = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 16, 7, Vec3.getVec3Pool().getVecFromPool((double)var1.posX, (double)var1.posY, (double)var1.posZ));
    031
    032                if (var2 == null)
    033                {
    034                    return false;
    035                }
    036                else
    037                {
    038                    this.movePosX = var2.xCoord;
    039                    this.movePosY = var2.yCoord;
    040                    this.movePosZ = var2.zCoord;
    041                    return true;
    042                }
    043            }
    044        }
    045
    046        /**
    047         * Returns whether an in-progress EntityAIBase should continue executing
    048         */
    049        public boolean continueExecuting()
    050        {
    051            return !this.theEntity.getNavigator().noPath();
    052        }
    053
    054        /**
    055         * Execute a one shot task or start executing a continuous task
    056         */
    057        public void startExecuting()
    058        {
    059            this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.movementSpeed);
    060        }
    061    }