The bug
When you summon a mob only with a given value for the generic.max_health
attribute the value for the Health
tag is the default health value of this mob which can be higher than the value of the attribute generic.max_health
. If you however provide the Health
tag, the attribute value is used as maximum value.
How to reproduce
Use the following command
/summon wolf ~ ~ ~ {Attributes:[{Name:"generic.max_health",Base:0.1d}]}
Inspect the NBT data
/data get entity @e[type=wolf,limit=1] Health
❌ The
Health
value is the default8f
which is larger than the maximumUse the following command
Health provided
/summon wolf ~ ~ ~ {Attributes:[{Name:"generic.max_health",Base:0.1d}],Health:8f}
Inspect the NBT data
/data get entity @e[type=wolf,limit=1] Health
✔ Its
Health
value is now the value of thegeneric.max_health
attribute
Wrong max_health value is used
Not reproducible anymore in 20w07a (and probably earlier) because when summoning tame wolves their Health
is set as well.
Based on Skylinerw's comment on MC-93830 it also appears that the game is not using the value for the generic.max_health
attribute the mob has at the end.
The following command will cause Health
to be set to the maximum value defined by the generic.max_health
attribute in the command, however the game overrides this value with the default 20d
. This means the Health
value of 2f
would have been valid.
/summon wolf ~ ~1 ~ {OwnerUUID:"00000000-0000-0000-0000-000000000000",Attributes:[{Name:"generic.max_health",Base:0.1d}],Health:2f}
Linked issues
is duplicated by 2
Comments 6
Can confirm in 21w05a.
Can confirm in 21w06a.
Can confirm in 21w07a.
Can confirm in 1.16.5 and 21w08b.

For clarity, this report only covers the issue where Health was not capped at max health during initialization unless the tag was specified, which was fixed in 24w19a as part of the fix for part of MC-268106.
Can confirm in 21w03a.