Skip to content

Commit 887cd68

Browse files
committed
re-add showProtectionLevel to ArmorHUD
i guess that was forgotten to re-add after the port
1 parent 4effb0e commit 887cd68

File tree

1 file changed

+22
-3
lines changed
  • src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item

1 file changed

+22
-3
lines changed

src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package io.github.axolotlclient.modules.hud.gui.hud.item;
22

3+
import io.github.axolotlclient.AxolotlclientConfig.options.BooleanOption;
34
import io.github.axolotlclient.AxolotlclientConfig.options.Option;
45
import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry;
56
import io.github.axolotlclient.modules.hud.util.DrawPosition;
67
import io.github.axolotlclient.modules.hud.util.ItemUtil;
78
import net.minecraft.client.util.math.MatrixStack;
9+
import net.minecraft.enchantment.Enchantment;
810
import net.minecraft.item.ItemStack;
911
import net.minecraft.item.Items;
12+
import net.minecraft.nbt.NbtList;
1013
import net.minecraft.util.Identifier;
1114

1215
import java.util.List;
@@ -21,6 +24,8 @@ public class ArmorHud extends TextHudEntry {
2124

2225
public static final Identifier ID = new Identifier("kronhud", "armorhud");
2326

27+
protected BooleanOption showProtLvl = new BooleanOption("showProtectionLevel", false);
28+
2429
public ArmorHud() {
2530
super(20, 100, true);
2631
}
@@ -32,8 +37,20 @@ public void renderComponent(MatrixStack matrices, float delta) {
3237
renderMainItem(matrices, client.player.getInventory().getMainHandStack(), pos.x() + 2, pos.y() + lastY);
3338
lastY = lastY - 20;
3439
for (int i = 0; i <= 3; i++) {
35-
ItemStack item = client.player.getInventory().armor.get(i);
36-
renderItem(matrices, item, pos.x() + 2, lastY + pos.y());
40+
ItemStack stack = client.player.getInventory().getArmorStack(i).copy();
41+
if (showProtLvl.get() && stack.hasEnchantments()) {
42+
NbtList nbtList = stack.getEnchantments();
43+
if (nbtList != null) {
44+
for (int k = 0; k < nbtList.size(); ++k) {
45+
int enchantId = nbtList.getCompound(k).getShort("id");
46+
int level = nbtList.getCompound(k).getShort("lvl");
47+
if (enchantId == 0 && Enchantment.byRawId(enchantId) != null) {
48+
stack.setCount(level);
49+
}
50+
}
51+
}
52+
}
53+
renderItem(matrices, stack, pos.x() + 2, lastY + pos.y());
3754
lastY = lastY - 20;
3855
}
3956
}
@@ -85,7 +102,9 @@ public Identifier getId() {
85102

86103
@Override
87104
public List<Option<?>> getConfigurationOptions() {
88-
return super.getConfigurationOptions();
105+
List<Option<?>> options = super.getConfigurationOptions();
106+
options.add(showProtLvl);
107+
return options;
89108
}
90109

91110
}

0 commit comments

Comments
 (0)