From c560e50288d0a7523fbc9c1f6a1188296b01d09b Mon Sep 17 00:00:00 2001 From: Markil3 <75867393+Markil3@users.noreply.github.com> Date: Tue, 2 Mar 2021 10:41:53 -0700 Subject: [PATCH] Adjusts the health and hunger to always show under wither, poison, and hunger. --- .../markil3/immersive_hud/TimerUtils.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/markil3/immersive_hud/TimerUtils.java b/src/main/java/markil3/immersive_hud/TimerUtils.java index d80a5c4..8fcf235 100644 --- a/src/main/java/markil3/immersive_hud/TimerUtils.java +++ b/src/main/java/markil3/immersive_hud/TimerUtils.java @@ -615,7 +615,8 @@ public class TimerUtils } else if (effectinstance.getDuration() <= BLINK_TIME + potion.getFadeInTime()) { - effectAlpha = -(effectinstance.getDuration() - BLINK_TIME) / 22F + 0.454F; + effectAlpha = + -(effectinstance.getDuration() - BLINK_TIME) / 22F + 0.454F; } else { @@ -688,8 +689,7 @@ public class TimerUtils return true; } boolean changed = false; - boolean canceled = - healthTime == 0 && health / maxHealth > HEALTH_BOUNDARY; + boolean canceled; /** * Checks for a change in current or max health. @@ -718,13 +718,19 @@ public class TimerUtils * Only makes a change if the player is healthy. Otherwise, * the bar is shown. */ - if (health / maxHealth > HEALTH_BOUNDARY) + if (health / maxHealth > HEALTH_BOUNDARY && !entity + .hasStatusEffect(StatusEffects.WITHER) && !entity.hasStatusEffect( + StatusEffects.POISON)) { setAlpha(Main.getAlpha(healthTime, healthTimes.getMaxTime(), healthTimes.getFadeInTime(), healthTimes.getFadeOutTime())); } + canceled = + healthTime == 0 && health / maxHealth > HEALTH_BOUNDARY && !entity + .hasStatusEffect(StatusEffects.WITHER) && !entity.hasStatusEffect( + StatusEffects.POISON); return canceled; } @@ -792,14 +798,19 @@ public class TimerUtils { return true; } - else + /* + * Only makes a change if the player is healthy. Otherwise, + * the bar is shown. + */ + if (hunger > HUNGER_BOUNDARY && !entity.hasStatusEffect(StatusEffects.HUNGER)) { setAlpha(Main.getAlpha(hungerTime, hungerTimes.getMaxTime(), hungerTimes.getFadeInTime(), hungerTimes.getFadeOutTime())); - return false; } + return hungerTime == 0 && hunger > HUNGER_BOUNDARY && !entity + .hasStatusEffect(StatusEffects.HUNGER); } /**