Skip to content

Commit

Permalink
Fixed PotionTimers getting stuck invisible in the hud editor if all
Browse files Browse the repository at this point in the history
effects are hidden.
  • Loading branch information
thebest9178 authored and Wide-Cat committed Aug 13, 2023
1 parent b74432e commit a712a30
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -172,7 +172,7 @@ protected double alignX(double width, Alignment alignment) {

@Override
public void tick(HudRenderer renderer) {
if (mc.player == null || (isInEditor() && mc.player.getStatusEffects().isEmpty())) {
if (mc.player == null || (isInEditor() && hasNoVisibleEffects())) {
setSize(renderer.textWidth("Potion Timers 0:00", shadow.get(), getScale()), renderer.textHeight(shadow.get(), getScale()));
return;
}
@@ -199,7 +199,7 @@ public void render(HudRenderer renderer) {
renderer.quad(this.x, this.y, getWidth(), getHeight(), backgroundColor.get());
}

if (mc.player == null || (isInEditor() && mc.player.getStatusEffects().isEmpty())) {
if (mc.player == null || (isInEditor() && hasNoVisibleEffects())) {
renderer.text("Potion Timers 0:00", x, y, Color.WHITE, shadow.get(), getScale());
return;
}
@@ -251,6 +251,16 @@ private double getScale() {
return customScale.get() ? scale.get() : -1;
}

private boolean hasNoVisibleEffects() {
for (StatusEffectInstance statusEffectInstance : mc.player.getStatusEffects()) {
if (hiddenEffects.get().contains(statusEffectInstance.getEffectType())) continue;
if (!showAmbient.get() && statusEffectInstance.isAmbient()) continue;
return false;
}

return true;
}

public enum ColorMode {
Effect,
Flat,

0 comments on commit a712a30

Please sign in to comment.