Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit ed0cc24

Browse files
committed
(ArmorHud) add option to customize the durability number color
1 parent 670812b commit ed0cc24

File tree

6 files changed

+99
-25
lines changed
  • 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item
  • 1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item
  • 1.21.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item
  • 1.21/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item
  • 1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item
  • common/src/main/resources/assets/axolotlclient/lang

6 files changed

+99
-25
lines changed

1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
import java.util.stream.Stream;
2828

2929
import io.github.axolotlclient.AxolotlClientConfig.api.options.Option;
30+
import io.github.axolotlclient.AxolotlClientConfig.api.util.Colors;
3031
import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption;
32+
import io.github.axolotlclient.AxolotlClientConfig.impl.options.ColorOption;
3133
import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption;
3234
import io.github.axolotlclient.modules.hud.gui.component.DynamicallyPositionable;
3335
import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry;
@@ -59,6 +61,8 @@ public class ArmorHud extends TextHudEntry implements DynamicallyPositionable {
5961
new ItemStack(Items.IRON_SWORD)};
6062
private final BooleanOption showDurabilityNumber = new BooleanOption("show_durability_num", false);
6163
private final BooleanOption showMaxDurabilityNumber = new BooleanOption("show_max_durability_num", false);
64+
private final BooleanOption customDurabilityNumColor = new BooleanOption("armorhud.custom_durability_num_color", false);
65+
private final ColorOption durabilityNumColor = new ColorOption("armorhud.durability_num_color", Colors.WHITE);
6266
private final BooleanOption mainHandItemOnTop = new BooleanOption("armorhud.main_hand_item_top", false);
6367

6468
private final EnumOption<AnchorPoint> anchor = new EnumOption<>("anchorpoint", AnchorPoint.class,
@@ -138,11 +142,17 @@ private void renderDurabilityNumber(MatrixStack graphics, ItemStack stack, int x
138142
}
139143
String text = showDurability && showMaxDurability ? (stack.getMaxDamage() - stack.getDamage()) + "/" + stack.getMaxDamage() : String.valueOf((showDurability ? stack.getMaxDamage() - stack.getDamage() : stack.getMaxDamage()));
140144
int textY = y + 10 - client.textRenderer.fontHeight / 2;
141-
float f = (float) stack.getDamage();
142-
float g = (float) stack.getMaxDamage();
143-
float h = Math.max(0.0F, (g - f) / g);
144-
int j = MathHelper.hsvToRgb(h / 3.0F, 1.0F, 1.0F);
145-
drawStringWithShadow(graphics, client.textRenderer, text, x, textY, (((255 << 8) + (j >> 16 & 255) << 8) + (j >> 8 & 255) << 8) + (j & 255));
145+
int color;
146+
if (customDurabilityNumColor.get()) {
147+
color = durabilityNumColor.get().toInt();
148+
} else {
149+
float f = (float) stack.getDamage();
150+
float g = (float) stack.getMaxDamage();
151+
float h = Math.max(0.0F, (g - f) / g);
152+
int j = MathHelper.hsvToRgb(h / 3.0F, 1.0F, 1.0F);
153+
color = (((255 << 8) + (j >> 16 & 255) << 8) + (j >> 8 & 255) << 8) + (j & 255);
154+
}
155+
drawStringWithShadow(graphics, client.textRenderer, text, x, textY, color);
146156
}
147157

148158
@Override
@@ -160,13 +170,19 @@ public void renderPlaceholderComponent(MatrixStack matrices, float delta) {
160170
}
161171
DrawPosition pos = getPos();
162172
int lastY = 2 + (4 * 20);
163-
renderItem(matrices, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
164-
lastY = lastY - 20;
173+
boolean mainHandItemTop = mainHandItemOnTop.get();
174+
if (!mainHandItemTop) {
175+
renderItem(matrices, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
176+
lastY = lastY - 20;
177+
}
165178
for (int i = 0; i <= 3; i++) {
166179
ItemStack item = placeholderStacks[i];
167180
renderItem(matrices, item, pos.x() + 2, lastY + pos.y(), labelWidth);
168181
lastY = lastY - 20;
169182
}
183+
if (mainHandItemTop) {
184+
renderItem(matrices, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
185+
}
170186
}
171187

172188
@Override
@@ -180,6 +196,8 @@ public List<Option<?>> getConfigurationOptions() {
180196
options.add(showProtLvl);
181197
options.add(showDurabilityNumber);
182198
options.add(showMaxDurabilityNumber);
199+
options.add(customDurabilityNumColor);
200+
options.add(durabilityNumColor);
183201
options.add(anchor);
184202
options.add(mainHandItemOnTop);
185203
return options;

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
import java.util.stream.Stream;
2828

2929
import io.github.axolotlclient.AxolotlClientConfig.api.options.Option;
30+
import io.github.axolotlclient.AxolotlClientConfig.api.util.Colors;
3031
import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption;
32+
import io.github.axolotlclient.AxolotlClientConfig.impl.options.ColorOption;
3133
import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption;
3234
import io.github.axolotlclient.modules.hud.gui.component.DynamicallyPositionable;
3335
import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry;
@@ -58,6 +60,8 @@ public class ArmorHud extends TextHudEntry implements DynamicallyPositionable {
5860
new ItemStack(Items.IRON_SWORD)};
5961
private final BooleanOption showDurabilityNumber = new BooleanOption("show_durability_num", false);
6062
private final BooleanOption showMaxDurabilityNumber = new BooleanOption("show_max_durability_num", false);
63+
private final BooleanOption customDurabilityNumColor = new BooleanOption("armorhud.custom_durability_num_color", false);
64+
private final ColorOption durabilityNumColor = new ColorOption("armorhud.durability_num_color", Colors.WHITE);
6165
private final BooleanOption mainHandItemOnTop = new BooleanOption("armorhud.main_hand_item_top", false);
6266

6367
private final EnumOption<AnchorPoint> anchor = new EnumOption<>("anchorpoint", AnchorPoint.class,
@@ -135,7 +139,7 @@ private void renderDurabilityNumber(GuiGraphics graphics, ItemStack stack, int x
135139
}
136140
String text = showDurability && showMaxDurability ? (stack.getMaxDamage() - stack.getDamage()) + "/" + stack.getMaxDamage() : String.valueOf((showDurability ? stack.getMaxDamage() - stack.getDamage() : stack.getMaxDamage()));
137141
int textY = y + 10 - client.textRenderer.fontHeight / 2;
138-
graphics.drawShadowedText(client.textRenderer, text, x, textY, stack.getItemBarColor());
142+
graphics.drawShadowedText(client.textRenderer, text, x, textY, customDurabilityNumColor.get() ? durabilityNumColor.get().toInt() : stack.getItemBarColor());
139143
}
140144

141145
@Override
@@ -153,13 +157,19 @@ public void renderPlaceholderComponent(GuiGraphics graphics, float delta) {
153157
}
154158
DrawPosition pos = getPos();
155159
int lastY = 2 + (4 * 20);
156-
renderItem(graphics, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
157-
lastY = lastY - 20;
160+
boolean mainHandItemTop = mainHandItemOnTop.get();
161+
if (!mainHandItemTop) {
162+
renderItem(graphics, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
163+
lastY = lastY - 20;
164+
}
158165
for (int i = 0; i <= 3; i++) {
159166
ItemStack item = placeholderStacks[i];
160167
renderItem(graphics, item, pos.x() + 2, lastY + pos.y(), labelWidth);
161168
lastY = lastY - 20;
162169
}
170+
if (mainHandItemTop) {
171+
renderItem(graphics, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
172+
}
163173
}
164174

165175
@Override
@@ -173,6 +183,8 @@ public List<Option<?>> getConfigurationOptions() {
173183
options.add(showProtLvl);
174184
options.add(showDurabilityNumber);
175185
options.add(showMaxDurabilityNumber);
186+
options.add(customDurabilityNumColor);
187+
options.add(durabilityNumColor);
176188
options.add(anchor);
177189
options.add(mainHandItemOnTop);
178190
return options;

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
import java.util.stream.Stream;
2828

2929
import io.github.axolotlclient.AxolotlClientConfig.api.options.Option;
30+
import io.github.axolotlclient.AxolotlClientConfig.api.util.Colors;
3031
import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption;
32+
import io.github.axolotlclient.AxolotlClientConfig.impl.options.ColorOption;
3133
import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption;
3234
import io.github.axolotlclient.modules.hud.gui.component.DynamicallyPositionable;
3335
import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry;
@@ -59,6 +61,8 @@ public class ArmorHud extends TextHudEntry implements DynamicallyPositionable {
5961
new ItemStack(Items.IRON_CHESTPLATE), new ItemStack(Items.IRON_HELMET), new ItemStack(Items.IRON_SWORD)};
6062
private final BooleanOption showDurabilityNumber = new BooleanOption("show_durability_num", false);
6163
private final BooleanOption showMaxDurabilityNumber = new BooleanOption("show_max_durability_num", false);
64+
private final BooleanOption customDurabilityNumColor = new BooleanOption("armorhud.custom_durability_num_color", false);
65+
private final ColorOption durabilityNumColor = new ColorOption("armorhud.durability_num_color", Colors.WHITE);
6266
private final BooleanOption mainHandItemOnTop = new BooleanOption("armorhud.main_hand_item_top", false);
6367

6468
private final EnumOption<AnchorPoint> anchor = new EnumOption<>("anchorpoint", AnchorPoint.class,
@@ -128,9 +132,9 @@ private void renderDurabilityNumber(GuiGraphics graphics, ItemStack stack, int x
128132
return;
129133
}
130134
String text = showDurability && showMaxDurability ? (stack.getMaxDamage() - stack.getDamageValue()) + "/" + stack.getMaxDamage() : String.valueOf((showDurability ? stack.getMaxDamage() - stack.getDamageValue() : stack.getMaxDamage()));
131-
;
135+
132136
int textY = y + 10 - client.font.lineHeight / 2;
133-
graphics.drawString(client.font, text, x, textY, stack.getBarColor());
137+
graphics.drawString(client.font, text, x, textY, customDurabilityNumColor.get() ? durabilityNumColor.get().toInt() : stack.getBarColor());
134138
}
135139

136140
@Override
@@ -148,13 +152,19 @@ public void renderPlaceholderComponent(GuiGraphics graphics, float delta) {
148152
}
149153
DrawPosition pos = getPos();
150154
int lastY = 2 + (4 * 20);
151-
renderItem(graphics, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
152-
lastY = lastY - 20;
155+
boolean mainHandItemTop = mainHandItemOnTop.get();
156+
if (!mainHandItemTop) {
157+
renderItem(graphics, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
158+
lastY = lastY - 20;
159+
}
153160
for (int i = 0; i <= 3; i++) {
154161
ItemStack item = placeholderStacks[i];
155162
renderItem(graphics, item, pos.x() + 2, lastY + pos.y(), labelWidth);
156163
lastY = lastY - 20;
157164
}
165+
if (mainHandItemTop) {
166+
renderItem(graphics, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
167+
}
158168
}
159169

160170
@Override
@@ -168,6 +178,8 @@ public List<Option<?>> getConfigurationOptions() {
168178
options.add(showProtLvl);
169179
options.add(showDurabilityNumber);
170180
options.add(showMaxDurabilityNumber);
181+
options.add(customDurabilityNumColor);
182+
options.add(durabilityNumColor);
171183
options.add(anchor);
172184
options.add(mainHandItemOnTop);
173185
return options;

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
import java.util.stream.Stream;
2828

2929
import io.github.axolotlclient.AxolotlClientConfig.api.options.Option;
30+
import io.github.axolotlclient.AxolotlClientConfig.api.util.Colors;
3031
import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption;
32+
import io.github.axolotlclient.AxolotlClientConfig.impl.options.ColorOption;
3133
import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption;
3234
import io.github.axolotlclient.modules.hud.gui.component.DynamicallyPositionable;
3335
import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry;
@@ -60,6 +62,8 @@ public class ArmorHud extends TextHudEntry implements DynamicallyPositionable {
6062
new ItemStack(Items.IRON_SWORD)};
6163
private final BooleanOption showDurabilityNumber = new BooleanOption("show_durability_num", false);
6264
private final BooleanOption showMaxDurabilityNumber = new BooleanOption("show_max_durability_num", false);
65+
private final BooleanOption customDurabilityNumColor = new BooleanOption("armorhud.custom_durability_num_color", false);
66+
private final ColorOption durabilityNumColor = new ColorOption("armorhud.durability_num_color", Colors.WHITE);
6367
private final BooleanOption mainHandItemOnTop = new BooleanOption("armorhud.main_hand_item_top", false);
6468

6569
private final EnumOption<AnchorPoint> anchor = new EnumOption<>("anchorpoint", AnchorPoint.class,
@@ -134,7 +138,7 @@ private void renderDurabilityNumber(GuiGraphics graphics, ItemStack stack, int x
134138
}
135139
String text = showDurability && showMaxDurability ? (stack.getMaxDamage() - stack.getDamage()) + "/" + stack.getMaxDamage() : String.valueOf((showDurability ? stack.getMaxDamage() - stack.getDamage() : stack.getMaxDamage()));
136140
int textY = y + 10 - client.textRenderer.fontHeight / 2;
137-
graphics.drawShadowedText(client.textRenderer, text, x, textY, stack.getItemBarColor());
141+
graphics.drawShadowedText(client.textRenderer, text, x, textY, customDurabilityNumColor.get() ? durabilityNumColor.get().toInt() : stack.getItemBarColor());
138142
}
139143

140144
@Override
@@ -152,13 +156,19 @@ public void renderPlaceholderComponent(GuiGraphics graphics, float delta) {
152156
}
153157
DrawPosition pos = getPos();
154158
int lastY = 2 + (4 * 20);
155-
renderItem(graphics, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
156-
lastY = lastY - 20;
159+
boolean mainHandItemTop = mainHandItemOnTop.get();
160+
if (!mainHandItemTop) {
161+
renderItem(graphics, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
162+
lastY = lastY - 20;
163+
}
157164
for (int i = 0; i <= 3; i++) {
158165
ItemStack item = placeholderStacks[i];
159166
renderItem(graphics, item, pos.x() + 2, lastY + pos.y(), labelWidth);
160167
lastY = lastY - 20;
161168
}
169+
if (mainHandItemTop) {
170+
renderItem(graphics, placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
171+
}
162172
}
163173

164174
@Override
@@ -172,6 +182,8 @@ public List<Option<?>> getConfigurationOptions() {
172182
options.add(showProtLvl);
173183
options.add(showDurabilityNumber);
174184
options.add(showMaxDurabilityNumber);
185+
options.add(customDurabilityNumColor);
186+
options.add(durabilityNumColor);
175187
options.add(anchor);
176188
options.add(mainHandItemOnTop);
177189
return options;

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import java.util.stream.Stream;
2929

3030
import io.github.axolotlclient.AxolotlClientConfig.api.options.Option;
31+
import io.github.axolotlclient.AxolotlClientConfig.api.util.Colors;
3132
import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption;
33+
import io.github.axolotlclient.AxolotlClientConfig.impl.options.ColorOption;
3234
import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption;
3335
import io.github.axolotlclient.modules.hud.gui.component.DynamicallyPositionable;
3436
import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry;
@@ -58,6 +60,8 @@ public class ArmorHud extends TextHudEntry implements DynamicallyPositionable {
5860
new ItemStack(Items.IRON_SWORD)};
5961
private final BooleanOption showDurabilityNumber = new BooleanOption("show_durability_num", false);
6062
private final BooleanOption showMaxDurabilityNumber = new BooleanOption("show_max_durability_num", false);
63+
private final BooleanOption customDurabilityNumColor = new BooleanOption("armorhud.custom_durability_num_color", false);
64+
private final ColorOption durabilityNumColor = new ColorOption("armorhud.durability_num_color", Colors.WHITE);
6165
private final BooleanOption mainHandItemOnTop = new BooleanOption("armorhud.main_hand_item_top", false);
6266

6367
private final EnumOption<AnchorPoint> anchor = new EnumOption<>("anchorpoint", AnchorPoint.class,
@@ -140,11 +144,17 @@ private void renderDurabilityNumber(ItemStack stack, int x, int y) {
140144
}
141145
String text = showDurability && showMaxDurability ? (stack.getMaxDamage() - stack.getDamage()) + "/" + stack.getMaxDamage() : String.valueOf((showDurability ? stack.getMaxDamage() - stack.getDamage() : stack.getMaxDamage()));
142146
int textY = y + 10 - client.textRenderer.fontHeight / 2;
143-
float f = (float) stack.getDamage();
144-
float g = (float) stack.getMaxDamage();
145-
float h = Math.max(0.0F, (g - f) / g);
146-
int j = java.awt.Color.HSBtoRGB(h / 3.0F, 1.0F, 1.0F);
147-
drawString(client.textRenderer, text, x, textY, (((255 << 8) + (j >> 16 & 255) << 8) + (j >> 8 & 255) << 8) + (j & 255));
147+
int color;
148+
if (customDurabilityNumColor.get()) {
149+
color = durabilityNumColor.get().toInt();
150+
} else {
151+
float f = (float) stack.getDamage();
152+
float g = (float) stack.getMaxDamage();
153+
float h = Math.max(0.0F, (g - f) / g);
154+
int j = java.awt.Color.HSBtoRGB(h / 3.0F, 1.0F, 1.0F);
155+
color = (((255 << 8) + (j >> 16 & 255) << 8) + (j >> 8 & 255) << 8) + (j & 255);
156+
}
157+
drawString(client.textRenderer, text, x, textY, color);
148158
}
149159

150160
@Override
@@ -162,13 +172,19 @@ public void renderPlaceholderComponent(float delta) {
162172
}
163173
DrawPosition pos = getPos();
164174
int lastY = 2 + (4 * 20);
165-
renderItem(placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
166-
lastY = lastY - 20;
175+
boolean mainHandItemTop = mainHandItemOnTop.get();
176+
if (!mainHandItemTop) {
177+
renderItem(placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
178+
lastY = lastY - 20;
179+
}
167180
for (int i = 0; i <= 3; i++) {
168181
ItemStack item = placeholderStacks[i];
169182
renderItem(item, pos.x() + 2, lastY + pos.y(), labelWidth);
170183
lastY = lastY - 20;
171184
}
185+
if (mainHandItemTop) {
186+
renderItem(placeholderStacks[4], pos.x() + 2, pos.y() + lastY, labelWidth);
187+
}
172188
}
173189

174190
@Override
@@ -182,6 +198,8 @@ public List<Option<?>> getConfigurationOptions() {
182198
options.add(showProtLvl);
183199
options.add(showDurabilityNumber);
184200
options.add(showMaxDurabilityNumber);
201+
options.add(customDurabilityNumColor);
202+
options.add(durabilityNumColor);
185203
options.add(anchor);
186204
options.add(mainHandItemOnTop);
187205
return options;

common/src/main/resources/assets/axolotlclient/lang/en_us.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,5 +737,7 @@
737737
"playerstats.duels.uhc_four": "UHC (Fours)",
738738
"playerstats.duels.mode_title": "Stats in %s:",
739739
"armorhud.main_hand_item_top": "Main Hand Item above Armor",
740-
"itemupdatehud.bracket_color": "Separator (Bracket) Color"
740+
"itemupdatehud.bracket_color": "Separator (Bracket) Color",
741+
"armorhud.durability_num_color": "Durability Number Color",
742+
"armorhud.custom_durability_num_color": "Custom Durability Number Color"
741743
}

0 commit comments

Comments
 (0)