mojira.dev
MC-93833

Only if Health is provided maxHealth attribute is used as maximum Health value

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

  1. Use the following command

    /summon wolf ~ ~ ~ {Attributes:[{Name:"generic.max_health",Base:0.1d}]}
  2. Inspect the NBT data

    /data get entity @e[type=wolf,limit=1] Health

    ❌ The Health value is the default 8f which is larger than the maximum

  3. Use the following command

    Health provided

    /summon wolf ~ ~ ~ {Attributes:[{Name:"generic.max_health",Base:0.1d}],Health:8f}
  4. Inspect the NBT data

    /data get entity @e[type=wolf,limit=1] Health

    ✔ Its Health value is now the value of the generic.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

Comments 6

Avoma

Can confirm in 21w03a.

Avoma

Can confirm in 21w05a.

Avoma

Can confirm in 21w06a.

Avoma

Can confirm in 21w07a.

Avoma

Can confirm in 1.16.5 and 21w08b.

clamlol

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.

marcono1234

(Unassigned)

Confirmed

(Unassigned)

attribute, health, maxHealth

Minecraft 15w49b, Minecraft 1.10.2, Minecraft 16w43a, Minecraft 16w44a, Minecraft 1.11 Pre-Release 1, ..., 1.16.5, 21w05b, 21w06a, 21w07a, 21w08b

24w19a

Retrieved