mojira.dev
MC-99680

Heart jittering effect doesn't take absorption into account

The bug

The check to see if the player's hearts should shake only takes into account the actual health bar, not any health granted by the absorption status effect.

Steps to Reproduce by @unknown

  1. Ensure you are in survival or adventure mode:

    /gamemode survival
  2. Disable natural regeneration:

    /gamerule naturalRegeneration false
  3. Damage yourself by running the following command three times:

    /effect give @s instant_damage

    → ✔ Your health bar begins to shake

  4. Give yourself the absorption status effect:

    /effect give @s absorption

    → ❌ Your health bar continues to shake, despite your total health being greater than 4

Code analysis

Code analysis by @unknown can be found in this comment.

Attachments

Comments 16

The following is based on a decompiled version of Minecraft 1.12 using MCP 9.40pre-1. (Can confirm for 1.12.1)

In the method net.minecraft.client.gui.GuiIngame.renderPlayerStats() there is a small piece of code which modifies the y-position of the player's hearts in the ingame GUI by a random integer between 0 and 2 every tick if the player's health falls below 4 (2 hearts). However, this does not include hearts added by the absorption effect. This issue can be fixed very easily by adding those hearts added by absorption to the if-statement (entityplayer.getAbsorptionAmount()).

Suggested fix

793		int i = MathHelper.ceil(entityplayer.getHealth());
824		int k1 = MathHelper.ceil(entityplayer.getAbsorptionAmount());
// ...
889		if (i + k1 <= 4)
890		{
891			l4 += this.rand.nextInt(2);
892		}

imo wai, as absoprion can dissapear at any time. Absorption is like magic shield, when you are still injured.

Confirmed in 1.16.1.

  1. Ensure you are in survival or adventure mode:

    /gamemode survival
  2. Disable natural regeneration:

    /gamerule naturalRegeneration false
  3. Damage yourself by running the following command three times:

    /effect give @s instant_damage

    → ✔ Your health bar begins to shake

  4. Give yourself the absorption status effect:

    /effect give @s absorption

    → ❌ Your health bar continues to shake, despite your total health being greater than 4

Can confirm in 20w51a.

6 more comments

Can confirm in 1.16.5 and 21w08b.

Can confirm in 21w11a.

I can confirm that this was an issue in 21w20a, however, I can no longer reproduce this in 1.17 Pre-release 1, meaning that this issue was fixed in this version.

Is that 1.17 Pre-release 1 or 1.17.1 Pre-release 1? Either way, can confirm that this issue is not present in 1.17.1 Pre-release 2.

I just confirmed the fix version. It is 1.17 pre-1.

KingSupernova

(Unassigned)

Confirmed

UI

Minecraft 1.9.1 Pre-Release 3, Minecraft 1.10.2, Minecraft 16w42a, Minecraft 16w43a, Minecraft 1.12, ..., 21w05b, 21w06a, 21w07a, 21w08b, 21w11a

1.17 Pre-release 1

Retrieved