Skip to content

Commit

Permalink
"Show Empty" Setting
Browse files Browse the repository at this point in the history
Render barrier icons for slots with no armor
  • Loading branch information
machiecodes committed Jan 9, 2025
1 parent d52c036 commit 37575fa
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public class ArmorHud extends HudElement {
.build()
);

private final Setting<Boolean> showEmpty = sgGeneral.add(new BoolSetting.Builder()
.name("show-empty")
.description("Renders barrier icons for empty slots.")
.defaultValue(false)
.build()
);

// Durability

private final Setting<Durability> durability = sgDurability.add(new EnumSetting.Builder<Durability>()
Expand Down Expand Up @@ -122,12 +129,16 @@ private void calculateSize() {
public void render(HudRenderer renderer) {
double x = this.x;
double y = this.y;

double armorX;
double armorY;

int slot = flipOrder.get() ? 3 : 0;
int emptySlots = 0;

for (int position = 0; position < 4; position++) {
ItemStack itemStack = getItem(slot);
if (itemStack.isEmpty()) emptySlots++;

if (orientation.get() == Orientation.Vertical) {
armorX = x;
Expand Down Expand Up @@ -163,7 +174,7 @@ public void render(HudRenderer renderer) {
else slot++;
}

if (background.get()) {
if (background.get() && emptySlots < 4) {
renderer.quad(this.x, this.y, getWidth(), getHeight(), backgroundColor.get());
}
}
Expand All @@ -178,7 +189,8 @@ private ItemStack getItem(int i) {
};
}

return mc.player.getInventory().getArmorStack(i);
ItemStack stack = mc.player.getInventory().getArmorStack(i);
return stack.isEmpty() && showEmpty.get() ? Items.BARRIER.getDefaultStack() : stack;
}

private double getScale() {
Expand Down

0 comments on commit 37575fa

Please sign in to comment.