    001package net.minecraft.scoreboard;
    002
    003import java.util.Iterator;
    004import java.util.List;
    005import net.minecraft.entity.player.EntityPlayer;
    006import net.minecraft.util.MathHelper;
    007
    008public class ScoreHealthCriteria extends ScoreDummyCriteria
    009{
    010    public ScoreHealthCriteria(String par1Str)
    011    {
    012        super(par1Str);
    013    }
    014
    015    public int func_96635_a(List par1List)
    016    {
    017        float f = 0.0F;
    018        int i;
    019        float f1;
    020
    021        for (Iterator iterator = par1List.iterator(); iterator.hasNext(); f += (float)i / f1)
    022        {
    023            EntityPlayer entityplayer = (EntityPlayer)iterator.next();
    024            i = entityplayer.getHealth();
    025            f1 = (float)entityplayer.getMaxHealth();
    026
    027            if (i < 0)
    028            {
    029                i = 0;
    030            }
    031
    032            if ((float)i > f1)
    033            {
    034                i = entityplayer.getMaxHealth();
    035            }
    036        }
    037
    038        if (par1List.size() > 0)
    039        {
    040            f /= (float)par1List.size();
    041        }
    042
    043        return MathHelper.floor_float(f * 19.0F) + (f > 0.0F ? 1 : 0);
    044    }
    045
    046    public boolean isReadOnly()
    047    {
    048        return true;
    049    }
    050}