Skip to content

Commit

Permalink
fix drawing all tinkers' hearts on top of each others, and now only d…
Browse files Browse the repository at this point in the history
…raw the top most hearts
  • Loading branch information
Alexdoru committed Sep 13, 2023
1 parent a832242 commit 3e4ec7e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/tconstruct/client/HealthBarRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,15 @@ public void renderHealthbar(RenderGameOverlayEvent.Pre event) {
if (health > 20) {
// Render tinkers' hearts
mc.getTextureManager().bindTexture(TINKER_HEARTS);
for (int i = 0; i < health / 20; i++) {
for (int i = Math.max(0, health / 20 - 2); i < health / 20; i++) {
final int heartIndexMax = Math.min(10, (health - 20 * (i + 1)) / 2);
for (int j = 0; j < heartIndexMax; j++) {
int y = 0;
if (j == regen) y -= 2;
// full heart texture
this.drawTexturedModalRect(xBasePos + 8 * j, yBasePos + y, 18 * i, tinkerTextureY, 9, 9);
if ((i + 1) * 20 + j * 2 + 21 >= health) {
// full heart texture
this.drawTexturedModalRect(xBasePos + 8 * j, yBasePos + y, 18 * i, tinkerTextureY, 9, 9);
}
}
if (health % 2 == 1 && heartIndexMax < 10) {
int y = 0;
Expand Down

0 comments on commit 3e4ec7e

Please sign in to comment.