66import it .unimi .dsi .fastutil .objects .ObjectArrayList ;
77import java .util .List ;
88import net .fabricmc .fabric .api .client .event .lifecycle .v1 .ClientTickEvents ;
9- import net .minecraft .client .DeltaTracker ;
10- import net .minecraft .client .Minecraft ;
11- import net .minecraft .client .gui . GuiGraphicsExtractor ;
9+ import net .minecraft .client .MinecraftClient ;
10+ import net .minecraft .client .gui . DrawContext ;
11+ import net .minecraft .client .render . RenderTickCounter ;
1212
1313public class BetterHUDGUI implements ClientTickEvents .StartTick {
1414
@@ -20,15 +20,15 @@ public class BetterHUDGUI implements ClientTickEvents.StartTick {
2020
2121 public static int lineHeight = 1 ;
2222
23- private final Minecraft client = Minecraft .getInstance ();
23+ private final MinecraftClient client = MinecraftClient .getInstance ();
2424 private final List <CustomText > topLeftText = new ObjectArrayList <>();
2525 private final List <CustomText > topRightText = new ObjectArrayList <>();
2626 private final List <CustomText > bottomLeftList = new ObjectArrayList <>();
2727 private final List <CustomText > bottomRightText = new ObjectArrayList <>();
2828 private final List <CustomText > customPositionText = new ObjectArrayList <>();
2929
3030 @ Override
31- public void onStartTick (Minecraft client ) {
31+ public void onStartTick (MinecraftClient client ) {
3232 this .topLeftText .clear ();
3333 this .topRightText .clear ();
3434 this .bottomLeftList .clear ();
@@ -68,11 +68,11 @@ public void onStartTick(Minecraft client) {
6868 }
6969
7070 public void onHudRender (
71- GuiGraphicsExtractor drawContext ,
72- DeltaTracker tickCounter
71+ DrawContext drawContext ,
72+ RenderTickCounter tickCounter
7373 ) {
74- if (client .getDebugOverlay ().showDebugScreen ()) return ;
75- if (client .options .hideGui ) return ;
74+ if (client .getDebugHud ().shouldShowDebugHud ()) return ;
75+ if (client .options .hudHidden ) return ;
7676
7777 int x = horizontalMargin ;
7878 int y = verticalMargin ;
@@ -81,43 +81,43 @@ public void onHudRender(
8181 drawString (drawContext , text , x , y );
8282
8383 y +=
84- (client .font . lineHeight - 1 ) +
84+ (client .textRenderer . fontHeight - 1 ) +
8585 (verticalPadding * 2 ) +
8686 lineHeight ;
8787 }
8888
89- y = client .getWindow ().getGuiScaledHeight () - verticalMargin ;
89+ y = client .getWindow ().getScaledHeight () - verticalMargin ;
9090
9191 for (CustomText text : bottomLeftList ) {
92- y -= (client .font . lineHeight - 1 ) + (verticalPadding * 2 );
92+ y -= (client .textRenderer . fontHeight - 1 ) + (verticalPadding * 2 );
9393 drawString (drawContext , text , x , y );
9494 y -= lineHeight ;
9595 }
9696
9797 y = verticalMargin ;
9898 for (CustomText text : topRightText ) {
9999 int offset =
100- (client .font . width (text .text ) - 1 ) +
100+ (client .textRenderer . getWidth (text .text ) - 1 ) +
101101 (horizontalPadding * 2 ) +
102102 horizontalMargin ;
103- x = client .getWindow ().getGuiScaledWidth () - offset ;
103+ x = client .getWindow ().getScaledWidth () - offset ;
104104 drawString (drawContext , text , x , y );
105105
106106 y +=
107- (client .font . lineHeight - 1 ) +
107+ (client .textRenderer . fontHeight - 1 ) +
108108 (verticalPadding * 2 ) +
109109 lineHeight ;
110110 }
111111
112- y = client .getWindow ().getGuiScaledHeight () - verticalMargin ;
112+ y = client .getWindow ().getScaledHeight () - verticalMargin ;
113113 for (CustomText text : bottomRightText ) {
114114 int offset =
115- (client .font . width (text .text ) - 1 ) +
115+ (client .textRenderer . getWidth (text .text ) - 1 ) +
116116 (horizontalPadding * 2 ) +
117117 horizontalMargin ;
118- x = client .getWindow ().getGuiScaledWidth () - offset ;
118+ x = client .getWindow ().getScaledWidth () - offset ;
119119
120- y -= (client .font . lineHeight - 1 ) + (verticalPadding * 2 );
120+ y -= (client .textRenderer . fontHeight - 1 ) + (verticalPadding * 2 );
121121
122122 drawString (drawContext , text , x , y );
123123
@@ -129,13 +129,13 @@ public void onHudRender(
129129 float yPercent = text .customY / 100.0f ;
130130
131131 int maxX =
132- client .getWindow ().getGuiScaledWidth () -
132+ client .getWindow ().getScaledWidth () -
133133 (horizontalPadding * 2 ) -
134- (client .font . width (text .text ) - 1 );
134+ (client .textRenderer . getWidth (text .text ) - 1 );
135135 int maxY =
136- client .getWindow ().getGuiScaledHeight () -
136+ client .getWindow ().getScaledHeight () -
137137 (verticalPadding * 2 ) -
138- (client .font . lineHeight - 1 );
138+ (client .textRenderer . fontHeight - 1 );
139139
140140 int scaledX = (int ) (xPercent * maxX );
141141 int scaledY = (int ) (yPercent * maxY );
@@ -145,7 +145,7 @@ public void onHudRender(
145145 }
146146
147147 private void drawString (
148- GuiGraphicsExtractor drawContext ,
148+ DrawContext drawContext ,
149149 CustomText text ,
150150 int x ,
151151 int y
@@ -154,14 +154,14 @@ private void drawString(
154154 x ,
155155 y ,
156156 x +
157- (client .font . width (text .text ) - 1 ) +
157+ (client .textRenderer . getWidth (text .text ) - 1 ) +
158158 (horizontalPadding * 2 ),
159- y + (client .font . lineHeight - 1 ) + (verticalPadding * 2 ),
159+ y + (client .textRenderer . fontHeight - 1 ) + (verticalPadding * 2 ),
160160 text .backgroundColor
161161 );
162162
163- drawContext .text (
164- client .font ,
163+ drawContext .drawText (
164+ client .textRenderer ,
165165 text .text ,
166166 x + horizontalPadding ,
167167 y + verticalPadding ,
0 commit comments