Summary:
Using /attribute
to change minecraft:generic.max_health
base value to a value lower than the Health
value does not reduce the Health
value as would be expected.
Repo Steps:
Create a new world and run:
/attribute @s minecraft:generic.max_health base set 1
Expected Result:
Only 1, half-filled heart container visible.
Actual Result:
Only 1, fully filled heart container visible.
Verifying:
Running the following will show a value of 20.0f
:
/data get entity @s Health
Linked issues
duplicates 1
Attachments
Comments 14


Taking damage will set the players current health to whatever is set by generic.max_health if it is lower than 20.
Respawning will cause the attribute to reset to 20, but the amount of health that is visible is whatever it was set to before the player had died. See MC-179940.

Affects version 20w18a.

Affects version 20w19a

Affects 1.16.1

Affects 1.18.1. The full 10 hearts are now shown in the HUD after setting the base to 1
.

Could someone explain the difference between this issue and MC-16345? It seems to me that the core issue is the same (so this ticket should be closed as a duplicate) but this ticket specifically mentions /attribute as a means of reproducing it.

I don't know if it has already been mentioned but this also affects 1.19.1
I also don't know if this has been mentioned but I think it is also important to note that after taking any form of damage, it will display the correct amount, but the damage you take can be up to the original amount of health you had (eg. if you set the attribute for health to 1, you could still take 19 points of damage and still be alive because it displayed 20 hearts. Then it would display the half heart. Even if you only took 1 or 2 damage, it would revert to the half heart)

Can confirm in 1.19.2

Can confirm for 1.19.4.
This affects attribute modifiers, too. I distinctly remember it used to work as expected back in 1.8. At the time, I made some mob heads that reduced max health modifiers, and the health bar was updated instantly when the head was equipped. Now, the player has to be healed or hurt on the next tick in order for the health bar to update.
Not only does it give you full heart instead of a half, but if you take half a heart of damage you can't regenerate to a full heart. Weird bug.