    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.util.Comparator;
    006
    007    @SideOnly(Side.CLIENT)
    008    public class RenderSorter implements Comparator
    009    {
    010        /** The entity (usually the player) that the camera is inside. */
    011        private EntityLiving baseEntity;
    012
    013        public RenderSorter(EntityLiving par1EntityLiving)
    014        {
    015            this.baseEntity = par1EntityLiving;
    016        }
    017
    018        public int doCompare(WorldRenderer par1WorldRenderer, WorldRenderer par2WorldRenderer)
    019        {
    020            if (par1WorldRenderer.isInFrustum && !par2WorldRenderer.isInFrustum)
    021            {
    022                return 1;
    023            }
    024            else if (par2WorldRenderer.isInFrustum && !par1WorldRenderer.isInFrustum)
    025            {
    026                return -1;
    027            }
    028            else
    029            {
    030                double var3 = (double)par1WorldRenderer.distanceToEntitySquared(this.baseEntity);
    031                double var5 = (double)par2WorldRenderer.distanceToEntitySquared(this.baseEntity);
    032                return var3 < var5 ? 1 : (var3 > var5 ? -1 : (par1WorldRenderer.chunkIndex < par2WorldRenderer.chunkIndex ? 1 : -1));
    033            }
    034        }
    035
    036        public int compare(Object par1Obj, Object par2Obj)
    037        {
    038            return this.doCompare((WorldRenderer)par1Obj, (WorldRenderer)par2Obj);
    039        }
    040    }