001    package net.minecraft.src;
002    
003    import java.util.Comparator;
004    
005    public class PlayerPositionComparator implements Comparator
006    {
007        private final ChunkCoordinates theChunkCoordinates;
008    
009        public PlayerPositionComparator(ChunkCoordinates par1ChunkCoordinates)
010        {
011            this.theChunkCoordinates = par1ChunkCoordinates;
012        }
013    
014        /**
015         * Compare the position of two players.
016         */
017        public int comparePlayers(EntityPlayerMP par1EntityPlayerMP, EntityPlayerMP par2EntityPlayerMP)
018        {
019            double var3 = par1EntityPlayerMP.getDistanceSq((double)this.theChunkCoordinates.posX, (double)this.theChunkCoordinates.posY, (double)this.theChunkCoordinates.posZ);
020            double var5 = par2EntityPlayerMP.getDistanceSq((double)this.theChunkCoordinates.posX, (double)this.theChunkCoordinates.posY, (double)this.theChunkCoordinates.posZ);
021            return var3 < var5 ? -1 : (var3 > var5 ? 1 : 0);
022        }
023    
024        public int compare(Object par1Obj, Object par2Obj)
025        {
026            return this.comparePlayers((EntityPlayerMP)par1Obj, (EntityPlayerMP)par2Obj);
027        }
028    }