Skip to content

Commit

Permalink
Fix Background
Browse files Browse the repository at this point in the history
  • Loading branch information
machiecodes committed Jan 10, 2025
1 parent e431ee2 commit 182dd52
Showing 1 changed file with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
import meteordevelopment.meteorclient.systems.hud.HudElementInfo;
import meteordevelopment.meteorclient.systems.hud.HudRenderer;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;

import java.util.List;

import static meteordevelopment.meteorclient.MeteorClient.mc;

public class ArmorHud extends HudElement {
Expand Down Expand Up @@ -132,13 +135,26 @@ public void render(HudRenderer renderer) {

double armorX;
double armorY;

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

List<ItemStack> armor = List.of(
getItem(0),
getItem(1),
getItem(2),
getItem(3)
);
if (flipOrder.get()) armor = armor.reversed();

for (ItemStack stack : armor) {
if (stack.isEmpty()) emptySlots++;
}

if (background.get() && emptySlots < 4) {
renderer.quad(this.x, this.y, getWidth(), getHeight(), backgroundColor.get());
}

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

if (orientation.get() == Orientation.Vertical) {
armorX = x;
Expand Down Expand Up @@ -169,14 +185,9 @@ public void render(HudRenderer renderer) {

renderer.text(message, armorX, armorY, durabilityColor.get(), durabilityShadow.get());
}

if (flipOrder.get()) slot--;
else slot++;
}

if (background.get() && emptySlots < 4) {
renderer.quad(this.x, this.y, getWidth(), getHeight(), backgroundColor.get());
}

}

private ItemStack getItem(int i) {
Expand Down

0 comments on commit 182dd52

Please sign in to comment.