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