Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-171047

Player max health float values won't decrease from generic.maxHealth on items

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.15.2, 1.16.4
    • None
    • Windows 10, Java Version 1.8.0_221
    • Unconfirmed
    • (Unassigned)

      When a player puts on an item (in my case, a helmet) with a generic.maxHealth value of 0.x (Operation:1), then the player's health will increase to match. However, if the player then puts on an item with a generic.maxHealth value of 0.xx (less than the original) then the player's Health float value will only decrease to the next even float value up until the player takes sufficient damage to go below the intended value. (EDIT: this is what happens in 1.15.2. In 1.16.4, the float does not decrease at all.)

      For example: if I put on a helmet with a generic.maxHealth value of 0.2, and then remove it, delete it, and place a new helmet on with a generic.maxHealth value of 0.05, then my Health value will stay at 24 (but I will have one full extra heart) until I take half a heart of damage, at which point it changes to 21.0. This is the case if the generic.maxHealth attributes on each piece have the same UUID and if they each have different UUIDs.

      EDIT: To reproduce the bug (1.16.4):

      /give @p leather_helmet{AttributeModifiers:[

      {AttributeName:"generic.max_health",Name:"generic.max_health",Amount:0.2,Operation:1,UUID:[I;702444554,1324106507,-1506023134,1861994455],Slot:"head"}

      ]} 1

      Place this on your head, then run:
      data get entity @s Health

      Then run this command:

      /give @p leather_helmet{AttributeModifiers:[

      {AttributeName:"generic.max_health",Name:"generic.max_health",Amount:0.05,Operation:1,UUID:[I;-1594121462,1295467870,-1076869537,-1392330127],Slot:"head"}

      ]} 1

      Replace the old helm with the newly made one, then get your new player health. It will still say "24", despite visually being 22. Even then, the intended value should be 21.

      Running `effect give @s instant_damage 1 0 true` corrects the health value.

        1. Health_Item005.png
          Health_Item005.png
          14 kB
        2. Health_Item02.png
          Health_Item02.png
          13 kB
        3. Health005_after_dmg.png
          Health005_after_dmg.png
          19 kB
        4. Item_0.2.png
          Item_0.2.png
          115 kB
        5. Item_005.png
          Item_005.png
          101 kB

            Unassigned Unassigned
            Jake_Remmert Jake Remmert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: