1
1
package dynamic_fps .impl .feature .battery ;
2
2
3
+ import com .mojang .blaze3d .systems .RenderSystem ;
4
+ import com .mojang .blaze3d .vertex .PoseStack ;
3
5
import dynamic_fps .impl .util .ResourceLocations ;
4
6
import net .minecraft .client .Minecraft ;
5
- import net .minecraft .client .gui .GuiGraphics ;
7
+ import net .minecraft .client .gui .GuiComponent ;
6
8
import net .minecraft .client .gui .components .toasts .Toast ;
7
9
import net .minecraft .client .gui .components .toasts .ToastComponent ;
8
10
import net .minecraft .network .chat .Component ;
@@ -20,6 +22,8 @@ public class BatteryToast implements Toast {
20
22
21
23
private static BatteryToast queuedToast ;
22
24
25
+ private static final Minecraft MINECRAFT = Minecraft .getInstance ();
26
+
23
27
private static final ResourceLocation MOD_ICON = ResourceLocations .of ("dynamic_fps" , "textures/battery/toast/background_icon.png" );
24
28
private static final ResourceLocation BACKGROUND_IMAGE = ResourceLocations .of ("dynamic_fps" , "textures/battery/toast/background.png" );
25
29
@@ -43,7 +47,7 @@ public static void queueToast(Component title, ResourceLocation icon) {
43
47
}
44
48
45
49
@ Override
46
- public @ NotNull Visibility render (GuiGraphics graphics , ToastComponent toastComponent , long currentTime ) {
50
+ public @ NotNull Visibility render (PoseStack poseStack , ToastComponent toastComponent , long currentTime ) {
47
51
if (this .firstRender == 0 ) {
48
52
if (this == queuedToast ) {
49
53
queuedToast = null ;
@@ -54,15 +58,18 @@ public static void queueToast(Component title, ResourceLocation icon) {
54
58
this .description = localized ("toast" , "battery_charge" , BatteryTracker .charge ());
55
59
}
56
60
61
+ MINECRAFT .getTextureManager ().bind (BACKGROUND_IMAGE );
57
62
// resource, x, y, z, ?, ?, width, height, width, height
58
- graphics .blit (BACKGROUND_IMAGE , 0 , 0 , 0 , 0.0f , 0.0f , this .width (), this .height (), this .width (), this .height ());
63
+ GuiComponent .blit (poseStack , 0 , 0 , 0 , 0.0f , 0.0f , this .width (), this .height (), this .width (), this .height ());
59
64
60
- graphics .blit (MOD_ICON , 2 , 2 , 0 , 0.0f , 0.0f , 8 , 8 , 8 , 8 );
61
- graphics .blit (this .icon , 8 , 8 , 0 , 0.0f , 0.0f , 16 , 16 , 16 , 16 );
65
+ MINECRAFT .getTextureManager ().bind (MOD_ICON );
66
+ GuiComponent .blit (poseStack , 2 , 2 , 0 , 0.0f , 0.0f , 8 , 8 , 8 , 8 );
67
+ MINECRAFT .getTextureManager ().bind (this .icon );
68
+ GuiComponent .blit (poseStack , 8 , 8 , 0 , 0.0f , 0.0f , 16 , 16 , 16 , 16 );
62
69
63
- graphics .drawString (toastComponent .getMinecraft ().font , this .title , 30 , 7 , 0x5f3315 , false );
64
- graphics .drawString (toastComponent .getMinecraft ().font , this .description , 30 , 18 , -16777216 , false );
70
+ GuiComponent .drawString (poseStack , toastComponent .getMinecraft ().font , this .title , 30 , 7 , 0x5f3315 );
71
+ GuiComponent .drawString (poseStack , toastComponent .getMinecraft ().font , this .description , 30 , 18 , -16777216 );
65
72
66
- return currentTime - this .firstRender >= 5000.0 * toastComponent . getNotificationDisplayTimeMultiplier () ? Toast .Visibility .HIDE : Toast .Visibility .SHOW ;
73
+ return currentTime - this .firstRender >= 5000.0 ? Toast .Visibility .HIDE : Toast .Visibility .SHOW ;
67
74
}
68
75
}
0 commit comments