mojira.dev
MC-17876

Entities' health is capped at their base max health upon reload

The bug

When I give myself extra max health with an attribute, then gain health, log out and log back in there are empty hearts but not the health.

Steps to Reproduce:

  • Give yourself a diamond sword that grants double health and hold it in your main hand.

/give @s diamond_sword[attribute_modifiers={modifiers:[{type:"generic.max_health",amount:20.0,slot:mainhand,id:"extra_max_hp_from_sword",operation:add_value}]}]
  • Give yourself some regeneration.

/effect give @s minecraft:regeneration 3 3 false
  • Take note of the health you currently have.

  • Reload into the world and once again, take note of the health that you now have.

Observed Behavior:
Additional health granted with items that have attributes is lost upon reloading the world.

Expected Behavior:
Additional health granted with items that have attributes would not be lost upon reloading the world.

Linked issues

Attachments

Comments 30

I can confirm this in 13w24b

Confirmed.

Still present in 13w15a

@up You mean 13w25a?

@Dominik, Yes I meant 13w25a.

Also just confirmed with the 1.6 pre-release you don't even have to log out to lose the extra health. I gave myself the Health boost effect x 4, healed up and then the health just vanished and I was left with 10 empty hearts. Was in survival mode and the character body shuddered like I was taking damage but with not hurt sound. And that left me with an empty health boost.
I've just tested with the long regen potion. Every time the Health Boost Effect hits a 30 second mark the additional health is removed.

Oh and the health now remains after login, as long as it's within that 30 second window.

20 more comments

Can confirm this behavior in 21w39a. Here are some extra details regarding this problem.

The Bug:

Additional health granted with items that have attributes is lost upon reloading the world.

Steps to Reproduce:

  • Give yourself a diamond sword that grants double health and hold it in your main hand.

/give @s minecraft:diamond_sword{AttributeModifiers:[{AttributeName:"minecraft:generic.max_health",Amount:20,UUID:[I;1,2,3,4],Slot:"mainhand"}]}
  • Give yourself some regeneration.

/effect give @s minecraft:regeneration 3 3 false
  • Take note of the health you currently have.

  • Reload into the world and once again, take note of the health that you now have.

Observed Behavior:

Additional health granted with items that have attributes is lost upon reloading the world.

Expected Behavior:

Additional health granted with items that have attributes would not be lost upon reloading the world.

Can confirm in 1.18.2.

Can confirm in 1.19.

Can confirm for 23w33a.

(Approximate) expected behavior: On the first tick where a LivingEntity is being deserialized, don't run the check comparing health with LivingEntity.getMaxHealth() until the underlying field has been initialized to account for Attributes.
(Please. It's been 10 years.)

Can confirm for 1.21, also for Custom Enchantments using said perk (/Attribute one works however)

Pete Frisky

(Unassigned)

Confirmed

Platform

Normal

Commands, Player

health, maxHealth

Snapshot 13w24b, Snapshot 13w25a, Minecraft 1.6.2, Minecraft 1.6.4, Minecraft 13w42b, ..., 24w13a, 24w19b, 24w20a, 1.21 Pre-Release 4, 1.21

Minecraft 1.6, Minecraft 1.8

Retrieved