mojira.dev
MC-124708

Instant heal would kill your after lowering your max hp

When you lower your max hp by holding an item, for example

/give @p stone{AttributeModifiers:[{AttributeName:"generic.maxHealth",Name:"233",Slot:"mainhand",Operation:0,Amount:-10,UUIDMost:11,UUIDLeast:11}]} 1

This time your hp is actually 20 unless you refresh it by taking damage or being heal.

I was trying to refresh my hp by adding a instant heal effect.

What I expected to happen was my hp was lowered to 10 and nothing else happened.

What actually happened was things like I suddenly lose all of my hp and regained instantly, and "You died" screen displayed. When I click "respawn" button, nothing was happened.

Steps to Reproduce:
1. Ensure your hp is 20, and your game mode is survival or adventure.
2. Execute this command and hold the given item.

/give @p stone{AttributeModifiers:[{AttributeName:"generic.maxHealth",Name:"233",Slot:"mainhand",Operation:0,Amount:-10,UUIDMost:11,UUIDLeast:11}]} 1

3. Execute another command to add effect.

/effect give @p minecraft:instant_health 1 0

4. Click the respawn button, then you will find nothing happened.

[media]

[media]

Attachments

Comments 1

Added a screenshot that shows the glitched player model after running through the steps. Also, the armor I had on was not damaged before I died (keepinventory set to true), but each piece lost one point of durability upon updating my health.

My take on this issue is that you start with 20 hp, the item reduces it to 10 hp, but the game still thinks you have 20 hp. Upon updating health by healing/taking damage, death occurs. It's possible that when updating your health, the game realizes your max hp is now 10 and not 20, causing it to reduce your health by 10 in the form of damage. However, since your max hp is now read as 10, and the game just dealt 10 points of damage, it sees it as a fatal hit to the player, thus killing them. This might be speculation, but it seems to be what the game is doing when this issue occurs. Tested it with an item that modifies health by -8 when held, and updating my hp did not kill me.

Found multiple ways this issue occurs. Can be done by using multiple of these items with different modifiers. Examples:

Command template:
{} /give @p stone{AttributeModifiers:[{AttributeName:"generic.maxHealth",Name:"233",Slot:"mainhand",Operation:0,Amount:<value>,UUIDMost:11,UUIDLeast:11}]} 1 {}

  • Giving the player an item with value set to 20, healing to full health while holding the item, switching to an empty main hand slot, then updating health will kill you. In this case, setting value to 20 or more will cause the issue.

  • Giving the player 1 item with value set to 20, and 1 item with value set to 60, healing to full health while holding the item with a value of 60, switching the main hand to the item with a value of 20, then updating your health will kill you.

Basically, if the extra health you gain from these items (or maintain in the case of value=-10) is greater than or equal to the health you have while holding an item with a lower value, the game will kill you.

Kong Bai

(Unassigned)

Unconfirmed

Minecraft 18w05a

Retrieved