Mojira Archive
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}