Skip to content

Commit 111a60b

Browse files
committed
add custom crosshair texture
1 parent e893839 commit 111a60b

File tree

7 files changed

+95
-60
lines changed

7 files changed

+95
-60
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,8 @@
9393
- Complete README feature list (RoonMoonlight)
9494
- Weather Changer
9595
- Tablist Customisation
96+
97+
### 2.2.10
98+
99+
- Add a `graphical` option type
100+
- Add custom crosshair texture option

gradle.properties

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ loader_version = 0.18.1-beta.23
1111
qsl_version = 4.0.0-beta.3
1212

1313
# AxolotlClientConfig
14-
# config_version = 1.0.17
15-
config_version = 2.0.1
14+
config_version = 2.1.0-beta.8
1615

1716
# Mod Properties
18-
version = 2.2.9
17+
version = 2.2.10-beta.1
1918
maven_group = io.github.axolotlclient
2019
archives_base_name = AxolotlClient

src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,9 @@ public class AxolotlClientConfig extends ConfigHolder {
7777
color = (color << 8) + value.getGreen();
7878
color = (color << 8) + value.getRed();
7979

80-
for (int i = 0; i < 16; ++i) {
81-
for (int j = 0; j < 16; ++j) {
82-
if (i < 8) {
83-
nativeImage.setPixelColor(j, i, color);
84-
} else {
85-
int k = (int) ((1.0F - (float) j / 15.0F * 0.75F) * 255.0F);
86-
nativeImage.setPixelColor(j, i, k << 24 | 16777215);
87-
}
80+
for (int i = 0; i <8 ; ++i) {
81+
for (int j = 0; j <8; ++j) {
82+
nativeImage.setPixelColor(j, i, color);
8883
}
8984
}
9085

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

Lines changed: 76 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
import com.mojang.blaze3d.platform.GlStateManager;
2626
import com.mojang.blaze3d.systems.RenderSystem;
2727
import io.github.axolotlclient.AxolotlClientConfig.Color;
28-
import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption;
29-
import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption;
30-
import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption;
31-
import io.github.axolotlclient.AxolotlClientConfig.options.Option;
28+
import io.github.axolotlclient.AxolotlClientConfig.options.*;
3229
import io.github.axolotlclient.modules.hud.gui.AbstractHudEntry;
3330
import io.github.axolotlclient.modules.hud.gui.component.DynamicallyPositionable;
3431
import io.github.axolotlclient.modules.hud.gui.layout.AnchorPoint;
@@ -53,6 +50,7 @@
5350
/**
5451
* This implementation of Hud modules is based on KronHUD.
5552
* <a href="https://github.com/DarkKronicle/KronHUD">Github Link.</a>
53+
*
5654
* @license GPL-3.0
5755
*/
5856

@@ -71,10 +69,60 @@ public class CrosshairHud extends AbstractHudEntry implements DynamicallyPositio
7169
private final BooleanOption applyBlend = new BooleanOption("applyBlend", true);
7270
private final BooleanOption overrideF3 = new BooleanOption("overrideF3", false);
7371

72+
private final GraphicsOption customTextureGraphics = new GraphicsOption("customTextureGraphics",
73+
new int[][]{
74+
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
75+
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
76+
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
77+
new int[]{0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0},
78+
new int[]{0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0},
79+
new int[]{0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0},
80+
new int[]{0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0},
81+
new int[]{0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0},
82+
new int[]{0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0},
83+
new int[]{0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0},
84+
new int[]{0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0},
85+
new int[]{0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0},
86+
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
87+
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
88+
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
89+
});
90+
7491
public CrosshairHud() {
7592
super(15, 15);
7693
}
7794

95+
@Override
96+
public boolean movable() {
97+
return false;
98+
}
99+
100+
@Override
101+
public Identifier getId() {
102+
return ID;
103+
}
104+
105+
@Override
106+
public List<Option<?>> getConfigurationOptions() {
107+
List<Option<?>> options = super.getConfigurationOptions();
108+
options.add(type);
109+
options.add(customTextureGraphics);
110+
options.add(showInF5);
111+
options.add(overrideF3);
112+
options.add(applyBlend);
113+
options.add(defaultColor);
114+
options.add(entityColor);
115+
options.add(containerColor);
116+
options.add(attackIndicatorBackgroundColor);
117+
options.add(attackIndicatorForegroundColor);
118+
return options;
119+
}
120+
121+
@Override
122+
public boolean overridesF3() {
123+
return overrideF3.get();
124+
}
125+
78126
@Override
79127
public double getDefaultX() {
80128
return 0.5;
@@ -133,17 +181,30 @@ public void render(MatrixStack matrices, float delta) {
133181
RenderSystem.renderCrosshair(10);
134182
matrixStack.pop();
135183
RenderSystem.applyModelViewMatrix();
136-
} else if (type.get().equals(Crosshair.TEXTURE.toString())) {
184+
} else if (type.get().equals(Crosshair.TEXTURE.toString()) || type.get().equals(Crosshair.CUSTOM.toString())) {
137185
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
138-
RenderSystem.setShader(GameRenderer::getPositionTexShader);
139-
RenderSystem.setShaderTexture(0, DrawableHelper.GUI_ICONS_TEXTURE);
140-
141-
// Draw crosshair
142-
RenderSystem.setShaderColor((float) color.getRed() / 255, (float) color.getGreen() / 255,
143-
(float) color.getBlue() / 255, (float) color.getAlpha() / 255);
144-
client.inGameHud.drawTexture(matrices,
145-
(int) (((client.getWindow().getScaledWidth() / getScale()) - 15) / 2),
146-
(int) (((client.getWindow().getScaledHeight() / getScale()) - 15) / 2), 0, 0, 15, 15);
186+
if (type.get().equals(Crosshair.TEXTURE.toString())) {
187+
RenderSystem.setShader(GameRenderer::getPositionTexShader);
188+
RenderSystem.setShaderTexture(0, DrawableHelper.GUI_ICONS_TEXTURE);
189+
// Draw crosshair
190+
RenderSystem.setShaderColor((float) color.getRed() / 255, (float) color.getGreen() / 255,
191+
(float) color.getBlue() / 255, (float) color.getAlpha() / 255);
192+
client.inGameHud.drawTexture(matrices,
193+
(int) (((client.getWindow().getScaledWidth() / getScale()) - 15) / 2),
194+
(int) (((client.getWindow().getScaledHeight() / getScale()) - 15) / 2), 0, 0, 15, 15);
195+
} else {
196+
customTextureGraphics.bindTexture();
197+
// Draw crosshair
198+
RenderSystem.setShaderColor((float) color.getRed() / 255, (float) color.getGreen() / 255,
199+
(float) color.getBlue() / 255, (float) color.getAlpha() / 255);
200+
201+
drawTexture(matrices,
202+
(int) (((client.getWindow().getScaledWidth() / getScale()) - 15) / 2),
203+
(int) (((client.getWindow().getScaledHeight() / getScale()) - 15) / 2), 0, 0, 15, 15, 15, 15);
204+
205+
RenderSystem.setShaderTexture(0, DrawableHelper.GUI_ICONS_TEXTURE);
206+
}
207+
147208
RenderSystem.setShaderColor(1, 1, 1, 1);
148209

149210
// Draw attack indicator
@@ -205,46 +266,13 @@ public void renderPlaceholder(MatrixStack matrices, float delta) {
205266
// Shouldn't need this...
206267
}
207268

208-
@Override
209-
public boolean movable() {
210-
return false;
211-
}
212-
213-
@Override
214-
public Identifier getId() {
215-
return ID;
216-
}
217-
218-
@Override
219-
public List<Option<?>> getConfigurationOptions() {
220-
List<Option<?>> options = super.getConfigurationOptions();
221-
options.add(type);
222-
options.add(showInF5);
223-
options.add(overrideF3);
224-
options.add(applyBlend);
225-
options.add(defaultColor);
226-
options.add(entityColor);
227-
options.add(containerColor);
228-
options.add(attackIndicatorBackgroundColor);
229-
options.add(attackIndicatorForegroundColor);
230-
return options;
231-
}
232-
233-
@Override
234-
public boolean overridesF3() {
235-
return overrideF3.get();
236-
}
237-
238269
@Override
239270
public AnchorPoint getAnchor() {
240271
return AnchorPoint.MIDDLE_MIDDLE;
241272
}
242273

243274
@AllArgsConstructor
244275
public enum Crosshair {
245-
246-
CROSS("cross"), DOT("dot"), DIRECTION("direction"), TEXTURE("texture");
247-
248-
private final String value;
276+
CROSS, DOT, DIRECTION, TEXTURE, CUSTOM
249277
}
250278
}

src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ private CloseableHttpClient createHttpClient(){
6767
}
6868

6969
public void uploadImage(String url, File file){
70+
Util.sendChatMessage(Text.translatable("imageUploadStarted"));
7071
String downloadUrl = upload(url + "/api/stream", file);
7172

7273
if (downloadUrl.isEmpty()) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ public static void init() {
6868
setServers(Freelook.getInstance().enabled, () -> Freelook.getInstance().needsDisabling(), "hypixel", "mineplex", "gommehd", "nucleoid");
6969
setServers(((ToggleSprintHud) HudManager.getInstance().get(ToggleSprintHud.ID)).toggleSneak, NONE, "hypixel");
7070

71-
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> onServerJoin(Objects.requireNonNull(handler.m_uccwwurs()).address));
71+
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
72+
if(handler.m_uccwwurs() != null) {
73+
onServerJoin(Objects.requireNonNull(handler.m_uccwwurs()).address);
74+
}
75+
});
7276
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> clear());
7377

7478
ClientPlayConnectionEvents.INIT.register((handler0, client0) ->

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"BOTTOM_RIGHT.tooltip": "Bottom right corner",
99
"CENTER": "Center",
1010
"CROSS": "Cross",
11+
"CUSTOM": "Custom",
1112
"DIRECTION": "Direction",
1213
"DOT": "Dot",
1314
"DOWN_TOP": "Bottom → Top",
@@ -111,6 +112,7 @@
111112
"customColor.tooltip": "Whether to use a custom color for this Particle.",
112113
"customSky": "Custom Skies",
113114
"customSky.tooltip": "Whether to enable custom skies.",
115+
"customTextureGraphics": "Custom Texture",
114116
"customtextcolor": "Custom Text Color",
115117
"dateformat": "Date Format",
116118
"debugLogOutput": "Debug Log Output",
@@ -170,6 +172,7 @@
170172
"iconsonly": "Icons only",
171173
"imageSaved": "Saved!",
172174
"imageUploadFailure": "Failed to upload image! See the log for more details.",
175+
"imageUploadStarted": "Uploading Image...",
173176
"imageUploadSuccess": "Successfully uploaded image! Get it here:",
174177
"imageViewer": "Image Viewer",
175178
"inGuis": "Apply to GUIs",

0 commit comments

Comments
 (0)