Skip to content

Instantly share code, notes, and snippets.

@sathonay
Last active August 28, 2020 23:35
Show Gist options
  • Save sathonay/8f89c3823f10b055c2b36ba7ae2df9b9 to your computer and use it in GitHub Desktop.
Save sathonay/8f89c3823f10b055c2b36ba7ae2df9b9 to your computer and use it in GitHub Desktop.
package net.minecraft.client.gui.GuiIngame
private void renderPlayerStats(ScaledResolution p_180477_1_)
{
if (this.mc.getRenderViewEntity() instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)this.mc.getRenderViewEntity();
int i = MathHelper.ceiling_float_int(entityplayer.getHealth());
boolean flag = this.healthUpdateCounter > (long)this.updateCounter && (this.healthUpdateCounter - (long)this.updateCounter) / 3L % 2L == 1L;
if (i < this.playerHealth && entityplayer.hurtResistantTime > 0)
{
this.lastSystemTime = Minecraft.getSystemTime();
this.healthUpdateCounter = (long)(this.updateCounter + 20);
}
else if (i > this.playerHealth && entityplayer.hurtResistantTime > 0)
{
this.lastSystemTime = Minecraft.getSystemTime();
this.healthUpdateCounter = (long)(this.updateCounter + 10);
}
if (Minecraft.getSystemTime() - this.lastSystemTime > 1000L)
{
this.playerHealth = i;
this.lastPlayerHealth = i;
this.lastSystemTime = Minecraft.getSystemTime();
}
this.playerHealth = i;
int j = this.lastPlayerHealth;
this.rand.setSeed((long)(this.updateCounter * 312871));
boolean flag1 = false;
FoodStats foodstats = entityplayer.getFoodStats();
int k = foodstats.getFoodLevel();
int l = foodstats.getPrevFoodLevel();
IAttributeInstance iattributeinstance = entityplayer.getEntityAttribute(SharedMonsterAttributes.maxHealth);
int i1 = p_180477_1_.getScaledWidth() / 2 - 91;
int j1 = p_180477_1_.getScaledWidth() / 2 + 91;
int k1 = p_180477_1_.getScaledHeight() - 39;
float f = (float)iattributeinstance.getAttributeValue();
float f1 = entityplayer.getAbsorptionAmount();
int l1 = MathHelper.ceiling_float_int((f + f1) / 2.0F / 10.0F);
int i2 = Math.max(10 - (l1 - 2), 3);
int j2 = k1 - (l1 - 1) * i2 - 10;
float f2 = f1;
int k2 = entityplayer.getTotalArmorValue();
int l2 = -1;
if (entityplayer.isPotionActive(Potion.regeneration))
{
l2 = this.updateCounter % MathHelper.ceiling_float_int(f + 5.0F);
}
this.mc.mcProfiler.startSection("armor");
for (int i3 = 0; i3 < 10; ++i3)
{
if (k2 > 0)
{
int j3 = i1 + i3 * 8;
if (i3 * 2 + 1 < k2)
{
this.drawTexturedModalRect(j3, j2, 34, 9, 9, 9);
}
if (i3 * 2 + 1 == k2)
{
this.drawTexturedModalRect(j3, j2, 25, 9, 9, 9);
}
if (i3 * 2 + 1 > k2)
{
this.drawTexturedModalRect(j3, j2, 16, 9, 9, 9);
}
}
}
this.mc.mcProfiler.endStartSection("health");
for (int j5 = MathHelper.ceiling_float_int((f + f1) / 2.0F) - 1; j5 >= 0; --j5)
{
int k5 = 16;
if (entityplayer.isPotionActive(Potion.poison))
{
k5 += 36;
}
else if (entityplayer.isPotionActive(Potion.wither))
{
k5 += 72;
}
byte b0 = 0;
if (flag)
{
b0 = 1;
}
int k3 = MathHelper.ceiling_float_int((float)(j5 + 1) / 10.0F) - 1;
int l3 = i1 + j5 % 10 * 8;
int i4 = k1 - k3 * i2;
if (i <= 4)
{
i4 += this.rand.nextInt(2);
}
if (j5 == l2)
{
i4 -= 2;
}
byte b1 = 0;
if (entityplayer.worldObj.getWorldInfo().isHardcoreModeEnabled())
{
b1 = 5;
}
this.drawTexturedModalRect(l3, i4, 16 + b0 * 9, 9 * b1, 9, 9);
// NMC-1.8 - Remove flashing hearts
/*
if (flag)
{
if (j5 * 2 + 1 < j)
{
this.drawTexturedModalRect(l3, i4, k5 + 54, 9 * b1, 9, 9);
}
if (j5 * 2 + 1 == j)
{
this.drawTexturedModalRect(l3, i4, k5 + 63, 9 * b1, 9, 9);
}
}
*/
if (f2 <= 0.0F)
{
if (j5 * 2 + 1 < i)
{
this.drawTexturedModalRect(l3, i4, k5 + 36, 9 * b1, 9, 9);
}
if (j5 * 2 + 1 == i)
{
this.drawTexturedModalRect(l3, i4, k5 + 45, 9 * b1, 9, 9);
}
}
else
{
if (f2 == f1 && f1 % 2.0F == 1.0F)
{
this.drawTexturedModalRect(l3, i4, k5 + 153, 9 * b1, 9, 9);
}
else
{
this.drawTexturedModalRect(l3, i4, k5 + 144, 9 * b1, 9, 9);
}
f2 -= 2.0F;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment