Skip to content

[Bug Report] Multiple rows (and armor row) have a wrong offset #61

@sepulzera

Description

@sepulzera

Describe the bug
Having a mob with so much health, that more than 1 row of hearts get rendered. For instance, have a very high health mob, or reduce "Hearts per row (beta)" to a low value.

The row density seems to be way off. Plus, the armor bar calculates the height of the health bar wrong.

Expected behavior
If there are multiple rows being displayed, then the rows will be attached niceley to each other. No overlapping, no large margins.

Screenshots
Image

Desktop (please complete the following information):

  • Minecraft Version: 1.21.8
  • Java Version: 21
  • Mod Version: 21.6.0

Additional context
For me it seems that the calcuation for heartDensity is wrong (plus that the variable name isn't really describing, at it is the row height):
The calcuation includes the number of heartsTotal divided by heartsPerRow. But those values shouldn't affect the row height.

I suggest changing that to float rowHeight = (scale*10);, what seems to be the correct value if I am not mistaken. Then for the loop add this value for additional rows, something like this (note that I change some variables for better readability here):

float rowHeight = (scale*10);
double h = 0;

for (int isDrawingEmpty = 0; isDrawingEmpty < 2; isDrawingEmpty++) {
    h = -rowHeight; // first row should be rendered to h=0
    ...
    for (int heart = 0; heart < heartsTotal; heart++) {
        if (heart % heartsPerRow == 0) {
            h += rowHeight;
        }

This change should be mirrored to the armor rendering. OR pass the actual row height (variable h) to the renderArmorPoints method. This could be done by calling renderArmorPoints from renderHearts and renderNumber directly, though be careful to still render it with disabled health bar.

Also fixes

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions