55import net .minecraft .client .DeltaTracker ;
66import net .minecraft .client .Minecraft ;
77import net .minecraft .client .gui .GuiGraphics ;
8+ import net .minecraft .client .renderer .RenderPipelines ;
89import net .minecraft .resources .ResourceLocation ;
10+ import net .minecraft .util .ARGB ;
911import net .minecraft .util .Mth ;
1012
1113public class GlideHudRenderer {
@@ -45,22 +47,20 @@ public static void onHudRender(GuiGraphics context, DeltaTracker v) {
4547 int width = client .getWindow ().getGuiScaledWidth ();
4648
4749 context .pose ().pushMatrix ();
48- context .pose ().translate ((width - HudMod .getConfig ().xOffset ), height / 2f , 0 );
49- context .pose ().scale (HudMod .getConfig ().armorHudScale , HudMod .getConfig ().armorHudScale , 1f );
50- context .pose ().translate (0 , -24 , 0 );
51- if (ServerInfoData .getGamemode () == ServerInfoData .GAME_MODES .SCORE_ATTACK ) {context .pose ().translate (0 , 24 , 0 );}
52- context .setColor (1f , 1f , 1f , HudMod .getConfig ().transparency );
50+ context .pose ().translate ((width - HudMod .getConfig ().xOffset ), height / 2f );
51+ context .pose ().scale (HudMod .getConfig ().armorHudScale , HudMod .getConfig ().armorHudScale );
52+ context .pose ().translate (0 , -24 );
53+ if (ServerInfoData .getGamemode () == ServerInfoData .GAME_MODES .SCORE_ATTACK ) {context .pose ().translate (0 , 24 );}
5354 renderStopwatch (context , client );
5455 renderSpeedometer (context , client );
5556 if (ServerInfoData .getGamemode () == ServerInfoData .GAME_MODES .SCORE_ATTACK ) {renderScore (context , client );}
56- context .setColor (1f , 1f , 1f , 1f );
5757 context .pose ().popMatrix ();
5858 }
5959 }
6060
6161
6262 public static void renderStopwatch (GuiGraphics context , Minecraft client ) {
63- context .blit ( STOPWATCH , 0 , -50 ,0 , 0 , 16 ,16 ,16 , 16 );
63+ context .blitSprite ( RenderPipelines . GUI_TEXTURED , STOPWATCH , 0 , -50 ,16 ,16 , HudMod . getConfig (). transparency );
6464 if (GlideHudMod .TIMER_RUNNING ) {
6565 elapsed = GlideHudMod .ELAPSED_TIME ;
6666 GlideHudMod .FINAL_TIME = elapsed ; //This prevents the time from displaying 0 if the final time packet is not received.
@@ -73,33 +73,33 @@ public static void renderStopwatch(GuiGraphics context, Minecraft client) {
7373 int secondsindex = (seconds / 10 ) % 11 ;
7474 int minutesindex = (minutes / 5 ) % 11 ;
7575
76- context .blit ( SECONDS_HAND (secondsindex ), 0 , -50 ,0 , 0 , 16 ,16 ,16 , 16 );
77- context .blit ( MINUTES_HAND (minutesindex ), 0 , -50 ,0 , 0 , 16 ,16 ,16 , 16 );
76+ context .blitSprite ( RenderPipelines . GUI_TEXTURED , SECONDS_HAND (secondsindex ), 0 , -50 , 16 ,16 , HudMod . getConfig (). transparency );
77+ context .blitSprite ( RenderPipelines . GUI_TEXTURED , MINUTES_HAND (minutesindex ), 0 , -50 , 16 ,16 , HudMod . getConfig (). transparency );
7878
7979 String timer = String .format ("%d:%02d.%03d" , minutes , seconds , milliseconds );
8080
8181 int textWidth = client .font .width (timer );
82- context .pose ().scale (1.25f ,1.25f , 1.25f );
83- context .drawString (client .font , timer , (-4 - textWidth ), -38 , 0xffffff , true );
84- context .pose ().scale (0.8f ,0.8f , 0.8f );
82+ context .pose ().scale (1.25f ,1.25f );
83+ context .drawString (client .font , timer , (-4 - textWidth ), -38 , ARGB . white ( HudMod . getConfig (). transparency ) , true );
84+ context .pose ().scale (0.8f ,0.8f );
8585 }
8686
8787 public static void renderSpeedometer (GuiGraphics context , Minecraft client ) {
8888 double mps = client .player .getDeltaMovement ().horizontalDistance () * 20 ;
8989 int needleIndex = Mth .clamp (Mth .floor (0.24 * mps - 0.5 ), 0 , 11 );
90- context .blit ( SPEEDOMETER , 0 , -30 ,0 , 0 , 16 ,16 ,16 , 16 );
91- context .blit ( SPEEDOMETER_NEEDLE (needleIndex ), 0 , -30 ,0 , 0 , 16 ,16 , 16 , 16 );
90+ context .blitSprite ( RenderPipelines . GUI_TEXTURED , SPEEDOMETER , 0 , -30 ,16 ,16 , HudMod . getConfig (). transparency );
91+ context .blitSprite ( RenderPipelines . GUI_TEXTURED , SPEEDOMETER_NEEDLE (needleIndex ), 0 , -30 ,16 ,16 , HudMod . getConfig (). transparency );
9292
9393 String speed = String .format ("%.2f m/s" , mps );
9494 int textWidth = client .font .width (speed );
95- context .drawString (client .font , speed , (-4 - textWidth ), (-30 ), 0xffffff , true );
95+ context .drawString (client .font , speed , (-4 - textWidth ), (-30 ), ARGB . white ( HudMod . getConfig (). transparency ) , true );
9696 }
9797
9898 public static void renderScore (GuiGraphics context , Minecraft client ) {
9999 context .blit (SPEEDOMETER , 0 , -10 ,0 ,0 ,16 ,16 ,16 ,16 );
100100
101101 String score = String .valueOf (GlideHudMod .GLIDE_SCORE );
102102 int textWidth = client .font .width (score );
103- context .drawString (client .font , score , (-4 - textWidth ), (-30 ), 0xffffff , true );
103+ context .drawString (client .font , score , (-4 - textWidth ), (-30 ), ARGB . white ( HudMod . getConfig (). transparency ) , true );
104104 }
105105}
0 commit comments