    001    package net.minecraft.src;
    002
    003    public class PathEntity
    004    {
    005        /** The actual points in the path */
    006        private final PathPoint[] points;
    007
    008        /** PathEntity Array Index the Entity is currently targeting */
    009        private int currentPathIndex;
    010
    011        /** The total length of the path */
    012        private int pathLength;
    013
    014        public PathEntity(PathPoint[] par1ArrayOfPathPoint)
    015        {
    016            this.points = par1ArrayOfPathPoint;
    017            this.pathLength = par1ArrayOfPathPoint.length;
    018        }
    019
    020        /**
    021         * Directs this path to the next point in its array
    022         */
    023        public void incrementPathIndex()
    024        {
    025            ++this.currentPathIndex;
    026        }
    027
    028        /**
    029         * Returns true if this path has reached the end
    030         */
    031        public boolean isFinished()
    032        {
    033            return this.currentPathIndex >= this.pathLength;
    034        }
    035
    036        /**
    037         * returns the last PathPoint of the Array
    038         */
    039        public PathPoint getFinalPathPoint()
    040        {
    041            return this.pathLength > 0 ? this.points[this.pathLength - 1] : null;
    042        }
    043
    044        /**
    045         * return the PathPoint located at the specified PathIndex, usually the current one
    046         */
    047        public PathPoint getPathPointFromIndex(int par1)
    048        {
    049            return this.points[par1];
    050        }
    051
    052        public int getCurrentPathLength()
    053        {
    054            return this.pathLength;
    055        }
    056
    057        public void setCurrentPathLength(int par1)
    058        {
    059            this.pathLength = par1;
    060        }
    061
    062        public int getCurrentPathIndex()
    063        {
    064            return this.currentPathIndex;
    065        }
    066
    067        public void setCurrentPathIndex(int par1)
    068        {
    069            this.currentPathIndex = par1;
    070        }
    071
    072        /**
    073         * Gets the vector of the PathPoint associated with the given index.
    074         */
    075        public Vec3 getVectorFromIndex(Entity par1Entity, int par2)
    076        {
    077            double var3 = (double)this.points[par2].xCoord + (double)((int)(par1Entity.width + 1.0F)) * 0.5D;
    078            double var5 = (double)this.points[par2].yCoord;
    079            double var7 = (double)this.points[par2].zCoord + (double)((int)(par1Entity.width + 1.0F)) * 0.5D;
    080            return par1Entity.worldObj.getWorldVec3Pool().getVecFromPool(var3, var5, var7);
    081        }
    082
    083        /**
    084         * returns the current PathEntity target node as Vec3D
    085         */
    086        public Vec3 getPosition(Entity par1Entity)
    087        {
    088            return this.getVectorFromIndex(par1Entity, this.currentPathIndex);
    089        }
    090
    091        /**
    092         * Returns true if the EntityPath are the same. Non instance related equals.
    093         */
    094        public boolean isSamePath(PathEntity par1PathEntity)
    095        {
    096            if (par1PathEntity == null)
    097            {
    098                return false;
    099            }
    100            else if (par1PathEntity.points.length != this.points.length)
    101            {
    102                return false;
    103            }
    104            else
    105            {
    106                for (int var2 = 0; var2 < this.points.length; ++var2)
    107                {
    108                    if (this.points[var2].xCoord != par1PathEntity.points[var2].xCoord || this.points[var2].yCoord != par1PathEntity.points[var2].yCoord || this.points[var2].zCoord != par1PathEntity.points[var2].zCoord)
    109                    {
    110                        return false;
    111                    }
    112                }
    113
    114                return true;
    115            }
    116        }
    117
    118        /**
    119         * Returns true if the final PathPoint in the PathEntity is equal to Vec3D coords.
    120         */
    121        public boolean isDestinationSame(Vec3 par1Vec3)
    122        {
    123            PathPoint var2 = this.getFinalPathPoint();
    124            return var2 == null ? false : var2.xCoord == (int)par1Vec3.xCoord && var2.zCoord == (int)par1Vec3.zCoord;
    125        }
    126    }