001    package net.minecraft.util;
002    
003    public class ChunkCoordinates implements Comparable
004    {
005        public int posX;
006    
007        /** the y coordinate */
008        public int posY;
009    
010        /** the z coordinate */
011        public int posZ;
012    
013        public ChunkCoordinates() {}
014    
015        public ChunkCoordinates(int par1, int par2, int par3)
016        {
017            this.posX = par1;
018            this.posY = par2;
019            this.posZ = par3;
020        }
021    
022        public ChunkCoordinates(ChunkCoordinates par1ChunkCoordinates)
023        {
024            this.posX = par1ChunkCoordinates.posX;
025            this.posY = par1ChunkCoordinates.posY;
026            this.posZ = par1ChunkCoordinates.posZ;
027        }
028    
029        public boolean equals(Object par1Obj)
030        {
031            if (!(par1Obj instanceof ChunkCoordinates))
032            {
033                return false;
034            }
035            else
036            {
037                ChunkCoordinates var2 = (ChunkCoordinates)par1Obj;
038                return this.posX == var2.posX && this.posY == var2.posY && this.posZ == var2.posZ;
039            }
040        }
041    
042        public int hashCode()
043        {
044            return this.posX + this.posZ << 8 + this.posY << 16;
045        }
046    
047        /**
048         * Compare the coordinate with another coordinate
049         */
050        public int compareChunkCoordinate(ChunkCoordinates par1ChunkCoordinates)
051        {
052            return this.posY == par1ChunkCoordinates.posY ? (this.posZ == par1ChunkCoordinates.posZ ? this.posX - par1ChunkCoordinates.posX : this.posZ - par1ChunkCoordinates.posZ) : this.posY - par1ChunkCoordinates.posY;
053        }
054    
055        public void set(int par1, int par2, int par3)
056        {
057            this.posX = par1;
058            this.posY = par2;
059            this.posZ = par3;
060        }
061    
062        /**
063         * Returns the squared distance between this coordinates and the coordinates given as argument.
064         */
065        public float getDistanceSquared(int par1, int par2, int par3)
066        {
067            int var4 = this.posX - par1;
068            int var5 = this.posY - par2;
069            int var6 = this.posZ - par3;
070            return (float)(var4 * var4 + var5 * var5 + var6 * var6);
071        }
072    
073        /**
074         * Return the squared distance between this coordinates and the ChunkCoordinates given as argument.
075         */
076        public float getDistanceSquaredToChunkCoordinates(ChunkCoordinates par1ChunkCoordinates)
077        {
078            return this.getDistanceSquared(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ);
079        }
080    
081        public int compareTo(Object par1Obj)
082        {
083            return this.compareChunkCoordinate((ChunkCoordinates)par1Obj);
084        }
085    }