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

Commit 1b15f16

Browse files
committed
reach display
- update translations
1 parent 0e57130 commit 1b15f16

File tree

11 files changed

+373
-161
lines changed

11 files changed

+373
-161
lines changed

run/options.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version:3105
2-
quilt_available_resource_packs:["programer_art","vanilla","file/testpack","file/square_textured","file/astralex-sky-overlay-for-1-8--sgdsdrgdyhd38745634867djhfkgkdyh.zip","file/OF-Testpack","file/! §bNebula - [sky only]"]
2+
quilt_available_resource_packs:["programer_art","vanilla"]
33
autoJump:false
44
autoSuggestions:true
55
chatColors:true
@@ -38,7 +38,7 @@ ao:2
3838
prioritizeChunkUpdates:0
3939
biomeBlendRadius:2
4040
renderClouds:"false"
41-
resourcePacks:["vanilla","file/! §bNebula - [sky only]","file/testpack"]
41+
resourcePacks:["vanilla"]
4242
incompatibleResourcePacks:["file/! §bNebula - [sky only]","file/testpack"]
4343
lastServer:
4444
lang:en_us
@@ -112,8 +112,6 @@ key_key.hotbar.6:key.keyboard.6
112112
key_key.hotbar.7:key.keyboard.7
113113
key_key.hotbar.8:key.keyboard.8
114114
key_key.hotbar.9:key.keyboard.f
115-
key_key.dynamicfps.toggle_forced:key.keyboard.unknown
116-
key_key.dynamicfps.toggle_disabled:key.keyboard.unknown
117115
key_key.openHud:key.keyboard.right.shift
118116
key_key.toggleSprint:key.keyboard.k
119117
key_key.toggleSneak:key.keyboard.i

src/main/java/io/github/axolotlclient/config/options/EnumOption.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ protected CommandResponse onCommandExecution(String arg) {
9696
return new CommandResponse(true, "Successfully set "+getName()+" to "+get()+"!");
9797
}
9898

99+
for (int i=0;i<values.length;i++){
100+
if(arg.equalsIgnoreCase(values[i])){
101+
this.i=i;
102+
return new CommandResponse(true, "Successfully set "+getName()+" to "+get()+" (Index: "+i+")!");
103+
}
104+
}
105+
99106
try {
100107
int value = Integer.parseInt(arg);
101108
if(value>values.length-1 || value < 0){
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package io.github.axolotlclient.mixin;
2+
3+
import io.github.axolotlclient.modules.hud.HudManager;
4+
import io.github.axolotlclient.modules.hud.gui.hud.ReachDisplayHud;
5+
import io.github.axolotlclient.util.Util;
6+
import net.minecraft.client.MinecraftClient;
7+
import net.minecraft.entity.Entity;
8+
import net.minecraft.entity.EntityType;
9+
import net.minecraft.entity.player.PlayerEntity;
10+
import net.minecraft.world.World;
11+
import org.spongepowered.asm.mixin.Mixin;
12+
import org.spongepowered.asm.mixin.injection.At;
13+
import org.spongepowered.asm.mixin.injection.Inject;
14+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
15+
16+
@Mixin(PlayerEntity.class)
17+
public abstract class MixinPlayerEntity extends Entity {
18+
19+
public MixinPlayerEntity(EntityType<?> entityType, World world) {
20+
super(entityType, world);
21+
}
22+
23+
@Inject(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getAttributeValue(Lnet/minecraft/entity/attribute/EntityAttribute;)D"))
24+
public void getReach(Entity entity, CallbackInfo ci){
25+
if((Object)this == MinecraftClient.getInstance().player || entity.equals(MinecraftClient.getInstance().player)){
26+
ReachDisplayHud hud = (ReachDisplayHud) HudManager.getINSTANCE().get(ReachDisplayHud.ID);
27+
if(hud.isEnabled()){
28+
hud.updateDistance(Util.calculateDistance(super.getPos(), entity.getPos()));
29+
}
30+
}
31+
}
32+
}

src/main/java/io/github/axolotlclient/modules/hud/HudManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public void init(){
7979
add(new ItemUpdateHud());
8080
add(new PackDisplayHud());
8181
add(new RealTimeHud());
82+
add(new ReachDisplayHud());
8283

8384
entries.forEach((identifier, abstractHudEntry) -> abstractHudEntry.init());
8485
}

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.axolotlclient.modules.hud.gui.hud;
22

3+
import com.mojang.blaze3d.platform.GlStateManager;
34
import com.mojang.blaze3d.systems.RenderSystem;
45
import com.mojang.blaze3d.vertex.BufferBuilder;
56
import com.mojang.blaze3d.vertex.Tessellator;
@@ -41,7 +42,7 @@
4142
public class CrosshairHud extends AbstractHudEntry {
4243
public static final Identifier ID = new Identifier("kronhud", "crosshairhud");
4344

44-
private final EnumOption type = new EnumOption("crosshair_type", CrosshairOption.values(), CrosshairOption.TEXTURE);
45+
private final EnumOption type = new EnumOption("type", CrosshairOption.values(), CrosshairOption.TEXTURE);
4546
private final BooleanOption showInF5 = new BooleanOption("showInF5", false);
4647
public final BooleanOption showInF3 = new BooleanOption("showInF3", false);
4748
private final ColorOption defaultColor = new ColorOption("defaultcolor", "#FFFFFFFF");
@@ -71,16 +72,33 @@ public void render(MatrixStack matrices) {
7172
if(!client.options.getPerspective().isFirstPerson() && !showInF5.get())return;
7273

7374

75+
7476
scale(matrices);
7577
DrawPosition pos = new DrawPosition(MinecraftClient.getInstance().getWindow().getScaledWidth()/2 - width/2, MinecraftClient.getInstance().getWindow().getScaledHeight()/2 - height/2);
7678
Color color = getColor();
7779
if (Objects.equals(type.get(), CrosshairOption.DOT.toString())) {
80+
if(color==defaultColor.get()) {
81+
RenderSystem.enableBlend();
82+
RenderSystem.blendFuncSeparate(GlStateManager.class_4535.ONE_MINUS_DST_COLOR, GlStateManager.class_4534.ONE_MINUS_SRC_COLOR, GlStateManager.class_4535.ONE, GlStateManager.class_4534.ZERO);
83+
}
7884
fillRect(matrices, new Rectangle(pos.x + (width / 2) - 2, pos.y + (height / 2) - 2, 3, 3), color);
85+
if(color==defaultColor.get()) {
86+
RenderSystem.defaultBlendFunc();
87+
RenderSystem.disableBlend();
88+
}
7989
} else if (Objects.equals(type.get(), CrosshairOption.CROSS.toString())) {
90+
if(color==defaultColor.get()) {
91+
RenderSystem.enableBlend();
92+
RenderSystem.blendFuncSeparate(GlStateManager.class_4535.ONE_MINUS_DST_COLOR, GlStateManager.class_4534.ONE_MINUS_SRC_COLOR, GlStateManager.class_4535.ONE, GlStateManager.class_4534.ZERO);
93+
}
8094
fillRect(matrices, new Rectangle(pos.x + (width / 2) - 6, pos.y + (height / 2) - 1, 6, 1), color);
8195
fillRect(matrices, new Rectangle(pos.x + (width / 2), pos.y + (height / 2) - 1, 5, 1), color);
8296
fillRect(matrices, new Rectangle(pos.x + (width / 2) - 1, pos.y + (height / 2) - 6, 1, 6), color);
8397
fillRect(matrices, new Rectangle(pos.x + (width / 2) - 1, pos.y + (height / 2), 1, 5), color);
98+
if(color==defaultColor.get()) {
99+
RenderSystem.defaultBlendFunc();
100+
RenderSystem.disableBlend();
101+
}
84102
} else if (Objects.equals(type.get(), CrosshairOption.DIRECTION.toString())) {
85103
Camera camera = this.client.gameRenderer.getCamera();
86104
MatrixStack matrixStack = RenderSystem.getModelViewStack();
@@ -94,15 +112,24 @@ public void render(MatrixStack matrices) {
94112
matrixStack.pop();
95113
RenderSystem.applyModelViewMatrix();
96114
} else if (Objects.equals(type.get(), CrosshairOption.TEXTURE.toString())) {
115+
if(color==defaultColor.get()) {
116+
RenderSystem.enableBlend();
117+
RenderSystem.blendFuncSeparate(GlStateManager.class_4535.ONE_MINUS_DST_COLOR, GlStateManager.class_4534.ONE_MINUS_SRC_COLOR, GlStateManager.class_4535.ONE, GlStateManager.class_4534.ZERO);
118+
}
97119
RenderSystem.setShaderTexture(0, DrawableHelper.GUI_ICONS_TEXTURE);
98120

99121
// Draw crosshair
100122
RenderSystem.setShaderColor((float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, (float) color.getAlpha() / 255);
101123
client.inGameHud.drawTexture(matrices, (int) (((client.getWindow().getScaledWidth() / getScale()) - 15) / 2), (int) (((client.getWindow().getScaledHeight() / getScale()) - 15) / 2), 0, 0, 15, 15);
102124
RenderSystem.setShaderColor(1, 1, 1, 1);
103125

126+
if(color==defaultColor.get()) {
127+
RenderSystem.defaultBlendFunc();
128+
RenderSystem.disableBlend();
129+
}
104130
// Draw attack indicator
105131
if (this.client.options.getAttackIndicator().get() == AttackIndicator.CROSSHAIR) {
132+
106133
float progress = this.client.player.getAttackCooldownProgress(0.0F);
107134

108135
// Whether a cross should be displayed under the indicator
@@ -125,6 +152,7 @@ public void render(MatrixStack matrices) {
125152
}
126153
}
127154
}
155+
128156
if (this.client.options.getAttackIndicator().get() == AttackIndicator.CROSSHAIR) {
129157
float progress = this.client.player.getAttackCooldownProgress(0.0F);
130158
if (progress != 1.0F) {
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package io.github.axolotlclient.modules.hud.gui.hud;
2+
3+
import io.github.axolotlclient.config.options.IntegerOption;
4+
import io.github.axolotlclient.config.options.OptionBase;
5+
import net.minecraft.client.resource.language.I18n;
6+
import net.minecraft.util.Identifier;
7+
8+
import java.math.RoundingMode;
9+
import java.text.DecimalFormat;
10+
import java.time.Instant;
11+
import java.util.List;
12+
13+
public class ReachDisplayHud extends CleanHudEntry {
14+
15+
public static Identifier ID = new Identifier("axolotlclient", "reachdisplayhud");
16+
17+
public IntegerOption time = new IntegerOption("timeout", 2, 1, 20);
18+
public IntegerOption decimalPlaces = new IntegerOption("decimalplaces", 2, 0, 10);
19+
20+
public ReachDisplayHud(){
21+
super(100, 13);
22+
}
23+
24+
private String currentDist;
25+
private Instant lastTime = Instant.now();
26+
27+
@Override
28+
public Identifier getId() {
29+
return ID;
30+
}
31+
32+
@Override
33+
public String getValue() {
34+
return currentDist +" "+ I18n.translate("blocks");
35+
}
36+
37+
@Override
38+
public boolean tickable() {
39+
return true;
40+
}
41+
42+
@Override
43+
public void tick() {
44+
if(lastTime.getEpochSecond()+time.get()<Instant.now().getEpochSecond()){
45+
currentDist = "0";
46+
}
47+
}
48+
49+
public void updateDistance(double dist){
50+
StringBuilder format = new StringBuilder("##");
51+
if (decimalPlaces.get() > 0) {
52+
format.append(".");
53+
format.append("0".repeat(Math.max(0, decimalPlaces.get())));
54+
}
55+
DecimalFormat df = new DecimalFormat(format.toString());
56+
df.setRoundingMode(RoundingMode.CEILING);
57+
currentDist = df.format(dist);
58+
if(currentDist.startsWith(".")){
59+
currentDist="0"+currentDist;
60+
}
61+
lastTime = Instant.now();
62+
}
63+
64+
@Override
65+
public void addConfigOptions(List<OptionBase<?>> options) {
66+
super.addConfigOptions(options);
67+
options.add(time);
68+
options.add(decimalPlaces);
69+
}
70+
71+
@Override
72+
public String getPlaceholder() {
73+
return "25 "+ I18n.translate("blocks");
74+
}
75+
}

src/main/java/io/github/axolotlclient/util/Util.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.google.common.util.concurrent.ThreadFactoryBuilder;
66
import com.mojang.blaze3d.glfw.Window;
77
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
8-
import io.github.axolotlclient.config.options.OptionCategory;
98
import io.github.axolotlclient.modules.hud.util.DrawPosition;
109
import io.github.axolotlclient.modules.hud.util.Rectangle;
1110
import net.minecraft.client.MinecraftClient;
@@ -27,14 +26,14 @@
2726
import net.minecraft.scoreboard.Team;
2827
import net.minecraft.text.Text;
2928
import net.minecraft.unmapped.C_fijiyucq;
29+
import net.minecraft.util.math.Vec3d;
3030
import org.lwjgl.opengl.GL11;
3131
import org.quiltmc.qsl.command.api.client.ClientCommandManager;
3232
import org.quiltmc.qsl.command.api.client.QuiltClientCommandSource;
3333

3434
import java.util.ArrayList;
3535
import java.util.Collection;
3636
import java.util.Collections;
37-
import java.util.HashMap;
3837
import java.util.List;
3938
import java.util.Locale;
4039
import java.util.Objects;
@@ -96,6 +95,14 @@ else if (MinecraftClient.getInstance().getCurrentServerEntry() != null && Minecr
9695
return game;
9796
}
9897

98+
public static double calculateDistance(Vec3d pos1, Vec3d pos2){
99+
return calculateDistance(pos1.x, pos2.x, pos1.y, pos2.y, pos1.z, pos2.z);
100+
}
101+
102+
public static double calculateDistance(double x1, double x2, double y1, double y2, double z1, double z2) {
103+
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2) + Math.pow(z2 - z1, 2));
104+
}
105+
99106
public static DrawPosition toGlCoords(int x, int y){
100107
return toGlCoords(new DrawPosition(x, y));
101108
}

0 commit comments

Comments
 (0)