2525import com .mojang .blaze3d .platform .GlStateManager ;
2626import com .mojang .blaze3d .systems .RenderSystem ;
2727import 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 .*;
3229import io .github .axolotlclient .modules .hud .gui .AbstractHudEntry ;
3330import io .github .axolotlclient .modules .hud .gui .component .DynamicallyPositionable ;
3431import io .github .axolotlclient .modules .hud .gui .layout .AnchorPoint ;
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}
0 commit comments