- 7
- 0
Всем привет, я начал переделку хп меню в файле IngameGui.java. Я зашёл в тупик, я смог выводить хп полоской, но возникла проблема , мне надо выводить налаженные эффект по типу "золотые сердца, иссушение, отравление". В моём коде много мусора, но я не убираю его так как он может пригодится.
Сам код:
public void func_238457_e_(MatrixStack p_238454_1_, int p_238454_2_)
{
PlayerEntity playerentity = this.getRenderViewPlayer();
if (playerentity != null)
{
int i = MathHelper.ceil(playerentity.getHealth());
boolean flag = this.healthUpdateCounter > (long)this.ticks && (this.healthUpdateCounter - (long)this.ticks) / 3L % 2L == 1L;
long j = Util.milliTime();
if (i < this.playerHealth && playerentity.hurtResistantTime > 0)
{
this.lastSystemTime = j;
this.healthUpdateCounter = (long)(this.ticks + 20);
}
else if (i > this.playerHealth && playerentity.hurtResistantTime > 0)
{
this.lastSystemTime = j;
this.healthUpdateCounter = (long)(this.ticks + 10);
}
if (j - this.lastSystemTime > 1000L)
{
this.playerHealth = i;
this.lastPlayerHealth = i;
this.lastSystemTime = j;
}
this.playerHealth = i;
int k = this.lastPlayerHealth;
this.rand.setSeed((long)(this.ticks * 312871));
FoodStats foodstats = playerentity.getFoodStats();
int l = foodstats.getFoodLevel();
int i1 = this.scaledWidth / 2 - 91;
int j1 = this.scaledWidth / 2 + 91;
int k1 = this.scaledHeight - 60;
float f = (float)playerentity.getAttributeValue(Attributes.MAX_HEALTH);
int l1 = MathHelper.ceil(playerentity.getAbsorptionAmount());
int i2 = MathHelper.ceil((f + (float)l1) / 2.0F / 10.0F);
int j2 = Math.max(20 - (i2 - 2), 3);
int k2 = k1 - (i2 - 1) * j2 - 10;
int l2 = k1 - 20;
int i3 = l1;
int j3 = playerentity.getTotalArmorValue();
int k3 = -1;
if (playerentity.isPotionActive(Effects.REGENERATION))
{
k3 = this.ticks % MathHelper.ceil(f + 5.0F);
}
this.mc.getProfiler().endStartSection("health");
for (int l5 = MathHelper.ceil((f + (float)l1) / 2.0F) - 1; l5 >= 0; --l5)
{
int i6 = 16;
if (playerentity.isPotionActive(Effects.POISON))
{
i6 += 36;
}
else if (playerentity.isPotionActive(Effects.WITHER))
{
i6 += 72;
}
this.mc.getProfiler().startSection("healBar");
this.mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_HEAL_LOCATION);
int ig = (int) this.mc.player.hpxpBarCap();
int gg = (int) this.mc.player.getMaxHealth();
int j5 = 0;
if (playerentity.world.getWorldInfo().isHardcore())
{
j5 = 5;
}
if (ig > 0)
{
int jg = 40;
int kg = (int)(this.mc.player.getHealth() * 5.5F);
int kg1 = (int)(this.mc.player.getMaxHealth());
int lg = this.scaledHeight / 16 + 4;
int l2g = this.scaledHeight / 5 - 2;
int i2g = this.scaledHeight - 31 - 2;
int i1g = this.scaledWidth / 9 - 61;
int k4 = MathHelper.ceil((float)(l5 + 1) / 10.0F) - 1;
int l4 = i1 + l5 % 1 * 8;
int i5 = k1 - k4 * j2;
int r1 = l2g - kg ;
this.blit(p_238454_1_, l4, i5, 0, 5, i6 + 100, 12);
if (flag)
{
if (l5 * 2 + 1 < k)
{
this.blit(p_238454_1_, l4, i5, i6 + 0, 100, 3 , 12);
}
if (l5 * 2 + 1 == k)
{
this.blit(p_238454_1_, l4, i5, 0 , 100, 3 , 12);
}
}
if (i3 > 0)
{
if (i3 == l1 && l1 % 2 == 1)
{
this.blit(p_238454_1_, l4, i5, 0, 90, k - kg, 12);
}
else
{
this.blit(p_238454_1_, l4, i5, 85, 90, k - kg, 12);
i3 -= 2;
}
}
else
{
if (l5 * 2 + 1 < i)
{
this.blit(p_238454_1_, l4, i5, 0, 100, kg , 12);
}
if (l5 * 2 + 1 == i)
{
this.blit(p_238454_1_, l4, i5, 0, 100, kg, 9);
}
}
}
if (this.mc.player.getHealth() > 0)
{
this.mc.getProfiler().startSection("expLevel");
int j1g = 8453920;
if (Config.isCustomColors())
{
j1g = CustomColors.getExpBarTextColor(j1);
}
String s = "" + this.mc.player.getHealth();
int k1g = (this.scaledWidth - this.getFontRenderer().getStringWidth(s)) / 12;
int i1g = this.scaledHeight - 41 - 8;
this.getFontRenderer().drawString(p_238454_1_, s, (float)(k1g + 1), (float)i1g, 0);
this.getFontRenderer().drawString(p_238454_1_, s, (float)(k1g - 1), (float)i1g, 0);
this.getFontRenderer().drawString(p_238454_1_, s, (float)k1g, (float)(i1g + 1), 0);
this.getFontRenderer().drawString(p_238454_1_, s, (float)k1g, (float)(i1g - 1), 0);
this.getFontRenderer().drawString(p_238454_1_, s, (float)k1g, (float)i1g, j1g);
this.mc.getProfiler().endSection();
}
}
}
}