    001    package net.minecraft.src;
    002
    003    public class PathPoint
    004    {
    005        /** The x coordinate of this point */
    006        public final int xCoord;
    007
    008        /** The y coordinate of this point */
    009        public final int yCoord;
    010
    011        /** The z coordinate of this point */
    012        public final int zCoord;
    013
    014        /** A hash of the coordinates used to identify this point */
    015        private final int hash;
    016
    017        /** The index of this point in its assigned path */
    018        int index = -1;
    019
    020        /** The distance along the path to this point */
    021        float totalPathDistance;
    022
    023        /** The linear distance to the next point */
    024        float distanceToNext;
    025
    026        /** The distance to the target */
    027        float distanceToTarget;
    028
    029        /** The point preceding this in its assigned path */
    030        PathPoint previous;
    031
    032        /** Indicates this is the origin */
    033        public boolean isFirst = false;
    034
    035        public PathPoint(int par1, int par2, int par3)
    036        {
    037            this.xCoord = par1;
    038            this.yCoord = par2;
    039            this.zCoord = par3;
    040            this.hash = makeHash(par1, par2, par3);
    041        }
    042
    043        public static int makeHash(int par0, int par1, int par2)
    044        {
    045            return par1 & 255 | (par0 & 32767) << 8 | (par2 & 32767) << 24 | (par0 < 0 ? Integer.MIN_VALUE : 0) | (par2 < 0 ? 32768 : 0);
    046        }
    047
    048        /**
    049         * Returns the linear distance to another path point
    050         */
    051        public float distanceTo(PathPoint par1PathPoint)
    052        {
    053            float var2 = (float)(par1PathPoint.xCoord - this.xCoord);
    054            float var3 = (float)(par1PathPoint.yCoord - this.yCoord);
    055            float var4 = (float)(par1PathPoint.zCoord - this.zCoord);
    056            return MathHelper.sqrt_float(var2 * var2 + var3 * var3 + var4 * var4);
    057        }
    058
    059        public float func_75832_b(PathPoint par1PathPoint)
    060        {
    061            float var2 = (float)(par1PathPoint.xCoord - this.xCoord);
    062            float var3 = (float)(par1PathPoint.yCoord - this.yCoord);
    063            float var4 = (float)(par1PathPoint.zCoord - this.zCoord);
    064            return var2 * var2 + var3 * var3 + var4 * var4;
    065        }
    066
    067        public boolean equals(Object par1Obj)
    068        {
    069            if (!(par1Obj instanceof PathPoint))
    070            {
    071                return false;
    072            }
    073            else
    074            {
    075                PathPoint var2 = (PathPoint)par1Obj;
    076                return this.hash == var2.hash && this.xCoord == var2.xCoord && this.yCoord == var2.yCoord && this.zCoord == var2.zCoord;
    077            }
    078        }
    079
    080        public int hashCode()
    081        {
    082            return this.hash;
    083        }
    084
    085        /**
    086         * Returns true if this point has already been assigned to a path
    087         */
    088        public boolean isAssigned()
    089        {
    090            return this.index >= 0;
    091        }
    092
    093        public String toString()
    094        {
    095            return this.xCoord + ", " + this.yCoord + ", " + this.zCoord;
    096        }
    097    }