    001    package net.minecraft.src;
    002
    003    import java.util.Comparator;
    004
    005    public class EntityAINearestAttackableTargetSorter implements Comparator
    006    {
    007        private Entity theEntity;
    008
    009        final EntityAINearestAttackableTarget parent;
    010
    011        public EntityAINearestAttackableTargetSorter(EntityAINearestAttackableTarget par1EntityAINearestAttackableTarget, Entity par2Entity)
    012        {
    013            this.parent = par1EntityAINearestAttackableTarget;
    014            this.theEntity = par2Entity;
    015        }
    016
    017        public int compareDistanceSq(Entity par1Entity, Entity par2Entity)
    018        {
    019            double var3 = this.theEntity.getDistanceSqToEntity(par1Entity);
    020            double var5 = this.theEntity.getDistanceSqToEntity(par2Entity);
    021            return var3 < var5 ? -1 : (var3 > var5 ? 1 : 0);
    022        }
    023
    024        public int compare(Object par1Obj, Object par2Obj)
    025        {
    026            return this.compareDistanceSq((Entity)par1Obj, (Entity)par2Obj);
    027        }
    028    }