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

Commit 6318ac0

Browse files
committed
(CrosshairHud): Add option to use the custom attack indicator
1 parent 1994ac8 commit 6318ac0

File tree

6 files changed

+44
-32
lines changed

6 files changed

+44
-32
lines changed

1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public class CrosshairHud extends AbstractHudEntry implements DynamicallyPositio
7878
private final ColorOption attackIndicatorForegroundColor = new ColorOption("attackindicatorfg", ClientColors.WHITE);
7979
private final BooleanOption applyBlend = new BooleanOption("applyBlend", true);
8080
private final BooleanOption overrideF3 = new BooleanOption("overrideF3", false);
81+
private final BooleanOption customAttackIndicator = new BooleanOption("crosshairhud.custom_attack_indicator", false);
8182

8283
private final GraphicsOption customTextureGraphics = new GraphicsOption("customTextureGraphics",
8384
new int[][]{
@@ -123,6 +124,7 @@ public List<Option<?>> getConfigurationOptions() {
123124
options.add(defaultColor);
124125
options.add(entityColor);
125126
options.add(containerColor);
127+
options.add(customAttackIndicator);
126128
options.add(attackIndicatorBackgroundColor);
127129
options.add(attackIndicatorForegroundColor);
128130
return options;
@@ -212,34 +214,36 @@ public void render(MatrixStack matrices, float delta) {
212214

213215
RenderSystem.color4f(1, 1, 1, 1);
214216

215-
// Draw attack indicator
216-
x = (int) ((client.getWindow().getScaledWidth() / getScale()) / 2 - 8);
217-
y = (int) ((client.getWindow().getScaledHeight() / getScale()) / 2 - 7 + 16);
218-
ItemStack itemStack = this.client.player.getStackInHand(Hand.OFF_HAND);
219-
boolean bl = this.client.options.field_26808 == class_5512.field_26811;
220-
if (bl && itemStack.getItem() == Items.SHIELD && this.client.player.method_31233(itemStack)) {
221-
this.drawTexture(matrices, x, y, 52, 112, 16, 16);
222-
} else if (bl && this.client.player.isBlocking()) {
223-
this.drawTexture(matrices, x, y, 36, 112, 16, 16);
224-
} else if (this.client.options.attackIndicator == AttackIndicator.CROSSHAIR) {
225-
float f = this.client.player.getAttackCooldownProgress(0.0F);
226-
boolean bl2 = false;
227-
if (this.client.targetedEntity != null && this.client.targetedEntity instanceof LivingEntity && f >= 2.0F) {
228-
bl2 = ((EntityHitResult) this.client.crosshairTarget).method_31252() <= this.client.player.method_31239(0.0F);
229-
bl2 &= this.client.targetedEntity.isAlive();
230-
}
217+
if (!customAttackIndicator.get()) {
218+
// Draw attack indicator
219+
x = (int) ((client.getWindow().getScaledWidth() / getScale()) / 2 - 8);
220+
y = (int) ((client.getWindow().getScaledHeight() / getScale()) / 2 - 7 + 16);
221+
ItemStack itemStack = this.client.player.getStackInHand(Hand.OFF_HAND);
222+
boolean bl = this.client.options.field_26808 == class_5512.field_26811;
223+
if (bl && itemStack.getItem() == Items.SHIELD && this.client.player.method_31233(itemStack)) {
224+
this.drawTexture(matrices, x, y, 52, 112, 16, 16);
225+
} else if (bl && this.client.player.isBlocking()) {
226+
this.drawTexture(matrices, x, y, 36, 112, 16, 16);
227+
} else if (this.client.options.attackIndicator == AttackIndicator.CROSSHAIR) {
228+
float f = this.client.player.getAttackCooldownProgress(0.0F);
229+
boolean bl2 = false;
230+
if (this.client.targetedEntity != null && this.client.targetedEntity instanceof LivingEntity && f >= 2.0F) {
231+
bl2 = ((EntityHitResult) this.client.crosshairTarget).method_31252() <= this.client.player.method_31239(0.0F);
232+
bl2 &= this.client.targetedEntity.isAlive();
233+
}
231234

232-
if (bl2) {
233-
this.drawTexture(matrices, x, y, 68, 94, 16, 16);
234-
} else if (f > 1.3F && f < 2.0F) {
235-
float h = (f - 1.0F);
236-
int l = (int) (h * 17.0F);
237-
this.drawTexture(matrices, x, y, 36, 94, 16, 4);
238-
this.drawTexture(matrices, x, y, 52, 94, l, 4);
235+
if (bl2) {
236+
this.drawTexture(matrices, x, y, 68, 94, 16, 16);
237+
} else if (f > 1.3F && f < 2.0F) {
238+
float h = (f - 1.0F);
239+
int l = (int) (h * 17.0F);
240+
this.drawTexture(matrices, x, y, 36, 94, 16, 4);
241+
this.drawTexture(matrices, x, y, 52, 94, l, 4);
242+
}
239243
}
240244
}
241245
}
242-
if (indicator == AttackIndicator.CROSSHAIR && !type.get().equals(Crosshair.TEXTURE) && !type.get().equals(Crosshair.CUSTOM)) {
246+
if (((type.get().equals(Crosshair.TEXTURE) || type.get().equals(Crosshair.CUSTOM)) ? customAttackIndicator.get() : true) && indicator == AttackIndicator.CROSSHAIR) {
243247
float progress = this.client.player.getAttackCooldownProgress(0.0F) / 2;
244248
if (progress != 1.0F) {
245249
RenderUtil.drawRectangle(matrices, getRawX() + (getWidth() / 2) - 6, getRawY() + (getHeight() / 2) + 9,

1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public class CrosshairHud extends AbstractHudEntry implements DynamicallyPositio
7272
private final ColorOption attackIndicatorForegroundColor = new ColorOption("attackindicatorfg", ClientColors.WHITE);
7373
private final BooleanOption applyBlend = new BooleanOption("applyBlend", true);
7474
private final BooleanOption overrideF3 = new BooleanOption("overrideF3", false);
75+
private final BooleanOption customAttackIndicator = new BooleanOption("crosshairhud.custom_attack_indicator", false);
7576

7677
private final GraphicsOption customTextureGraphics = new GraphicsOption("customTextureGraphics",
7778
new int[][]{
@@ -117,6 +118,7 @@ public List<Option<?>> getConfigurationOptions() {
117118
options.add(defaultColor);
118119
options.add(entityColor);
119120
options.add(containerColor);
121+
options.add(customAttackIndicator);
120122
options.add(attackIndicatorBackgroundColor);
121123
options.add(attackIndicatorForegroundColor);
122124
return options;
@@ -209,7 +211,7 @@ public void render(GuiGraphics graphics, float delta) {
209211
RenderSystem.setShaderColor(1, 1, 1, 1);
210212

211213
// Draw attack indicator
212-
if (indicator == AttackIndicator.CROSSHAIR) {
214+
if (!customAttackIndicator.get() && indicator == AttackIndicator.CROSSHAIR) {
213215
float progress = this.client.player.getAttackCooldownProgress(0.0F);
214216

215217
// Whether a cross should be displayed under the indicator
@@ -232,7 +234,7 @@ public void render(GuiGraphics graphics, float delta) {
232234
}
233235
}
234236
}
235-
if (indicator == AttackIndicator.CROSSHAIR && !type.get().equals(Crosshair.TEXTURE) && !type.get().equals(Crosshair.CUSTOM)) {
237+
if (((type.get().equals(Crosshair.TEXTURE) || type.get().equals(Crosshair.CUSTOM)) ? customAttackIndicator.get() : true) && indicator == AttackIndicator.CROSSHAIR) {
236238
float progress = this.client.player.getAttackCooldownProgress(0.0F);
237239
if (progress != 1.0F) {
238240
RenderUtil.drawRectangle(graphics, getRawX() + (getWidth() / 2) - 6, getRawY() + (getHeight() / 2) + 9,

1.21.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public class CrosshairHud extends AbstractHudEntry implements DynamicallyPositio
7777
private final ColorOption attackIndicatorForegroundColor = new ColorOption("attackindicatorfg", ClientColors.WHITE);
7878
private final BooleanOption applyBlend = new BooleanOption("applyBlend", true);
7979
private final BooleanOption overrideF3 = new BooleanOption("overrideF3", false);
80+
private final BooleanOption customAttackIndicator = new BooleanOption("crosshairhud.custom_attack_indicator", false);
8081

8182
private final GraphicsOption customTextureGraphics = new GraphicsOption("customTextureGraphics",
8283
new int[][]{
@@ -122,6 +123,7 @@ public List<Option<?>> getConfigurationOptions() {
122123
options.add(defaultColor);
123124
options.add(entityColor);
124125
options.add(containerColor);
126+
options.add(customAttackIndicator);
125127
options.add(attackIndicatorBackgroundColor);
126128
options.add(attackIndicatorForegroundColor);
127129
return options;
@@ -205,7 +207,7 @@ public void renderCrosshair(GuiGraphics graphics, float delta) {
205207
}
206208

207209
// Draw attack indicator
208-
if (indicator == AttackIndicatorStatus.CROSSHAIR) {
210+
if (!customAttackIndicator.get() && indicator == AttackIndicatorStatus.CROSSHAIR) {
209211
float progress = this.client.player.getAttackStrengthScale(0.0F);
210212

211213
// Whether a cross should be displayed under the indicator
@@ -228,7 +230,7 @@ public void renderCrosshair(GuiGraphics graphics, float delta) {
228230
}
229231
}
230232
}
231-
if (indicator == AttackIndicatorStatus.CROSSHAIR && !type.get().equals(Crosshair.TEXTURE) && !type.get().equals(Crosshair.CUSTOM)) {
233+
if (((type.get().equals(Crosshair.TEXTURE) || type.get().equals(Crosshair.CUSTOM)) ? customAttackIndicator.get() : true) && indicator == AttackIndicatorStatus.CROSSHAIR) {
232234
float progress = this.client.player.getAttackStrengthScale(0.0F);
233235
if (progress != 1.0F) {
234236
fillRenderType(graphics, blend, getRawX() + (getWidth() / 2) - 6, getRawY() + (getHeight() / 2) + 9,

1.21/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public class CrosshairHud extends AbstractHudEntry implements DynamicallyPositio
7575
private final ColorOption attackIndicatorForegroundColor = new ColorOption("attackindicatorfg", ClientColors.WHITE);
7676
private final BooleanOption applyBlend = new BooleanOption("applyBlend", true);
7777
private final BooleanOption overrideF3 = new BooleanOption("overrideF3", false);
78+
private final BooleanOption customAttackIndicator = new BooleanOption("crosshairhud.custom_attack_indicator", false);
7879

7980
private final GraphicsOption customTextureGraphics = new GraphicsOption("customTextureGraphics",
8081
new int[][]{
@@ -120,6 +121,7 @@ public List<Option<?>> getConfigurationOptions() {
120121
options.add(defaultColor);
121122
options.add(entityColor);
122123
options.add(containerColor);
124+
options.add(customAttackIndicator);
123125
options.add(attackIndicatorBackgroundColor);
124126
options.add(attackIndicatorForegroundColor);
125127
return options;
@@ -212,7 +214,7 @@ public void render(GuiGraphics graphics, float delta) {
212214
RenderSystem.setShaderColor(1, 1, 1, 1);
213215

214216
// Draw attack indicator
215-
if (indicator == AttackIndicator.CROSSHAIR) {
217+
if (!customAttackIndicator.get() && indicator == AttackIndicator.CROSSHAIR) {
216218
float progress = this.client.player.getAttackCooldownProgress(0.0F);
217219

218220
// Whether a cross should be displayed under the indicator
@@ -235,7 +237,7 @@ public void render(GuiGraphics graphics, float delta) {
235237
}
236238
}
237239
}
238-
if (indicator == AttackIndicator.CROSSHAIR && !type.get().equals(Crosshair.TEXTURE) && !type.get().equals(Crosshair.CUSTOM)) {
240+
if (((type.get().equals(Crosshair.TEXTURE) || type.get().equals(Crosshair.CUSTOM)) ? customAttackIndicator.get() : true) && indicator == AttackIndicator.CROSSHAIR) {
239241
float progress = this.client.player.getAttackCooldownProgress(0.0F);
240242
if (progress != 1.0F) {
241243
RenderUtil.drawRectangle(graphics, getRawX() + (getWidth() / 2) - 6, getRawY() + (getHeight() / 2) + 9,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,5 +739,7 @@
739739
"armorhud.main_hand_item_top": "Main Hand Item above Armor",
740740
"itemupdatehud.bracket_color": "Separator (Bracket) Color",
741741
"armorhud.durability_num_color": "Durability Number Color",
742-
"armorhud.custom_durability_num_color": "Custom Durability Number Color"
742+
"armorhud.custom_durability_num_color": "Custom Durability Number Color",
743+
"crosshairhud.custom_attack_indicator": "Custom Attack Indicator",
744+
"crosshairhud.custom_attack_indicator.tooltip": "Whether to use a custom attack indicator. <br>This only affects the \"Texture\" and \"Custom\" types. <br>\"Dot\" and \"Cross\" types always use the custom indicator."
743745
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.parallel=true
66
axolotlclient.modules.all=true
77

88
# Mod Properties
9-
version=3.1.2-beta.2
9+
version=3.1.2-beta.3
1010

1111
maven_group=io.github.axolotlclient
1212

0 commit comments

Comments
 (0)