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