2
2
3
3
import dynamic_fps .impl .util .ResourceLocations ;
4
4
import net .minecraft .client .Minecraft ;
5
- import net .minecraft .client .gui .Font ;
6
5
import net .minecraft .client .gui .GuiGraphics ;
7
6
import net .minecraft .client .gui .components .toasts .Toast ;
8
- import net .minecraft .client .gui .components .toasts .ToastManager ;
9
- import net .minecraft .client .renderer .RenderType ;
7
+ import net .minecraft .client .gui .components .toasts .ToastComponent ;
10
8
import net .minecraft .network .chat .Component ;
11
9
import net .minecraft .resources .ResourceLocation ;
12
10
import org .jetbrains .annotations .NotNull ;
@@ -19,7 +17,6 @@ public class BatteryToast implements Toast {
19
17
private Component title ;
20
18
private Component description ;
21
19
private ResourceLocation icon ;
22
- private Visibility visibility ;
23
20
24
21
private static BatteryToast queuedToast ;
25
22
@@ -29,7 +26,6 @@ public class BatteryToast implements Toast {
29
26
private BatteryToast (Component title , ResourceLocation icon ) {
30
27
this .title = title ;
31
28
this .icon = icon ;
32
- this .visibility = Visibility .SHOW ;
33
29
}
34
30
35
31
/**
@@ -42,28 +38,12 @@ public static void queueToast(Component title, ResourceLocation icon) {
42
38
queuedToast .icon = icon ;
43
39
} else {
44
40
queuedToast = new BatteryToast (title , icon );
45
- Minecraft .getInstance ().getToastManager ().addToast (queuedToast );
41
+ Minecraft .getInstance ().getToasts ().addToast (queuedToast );
46
42
}
47
43
}
48
44
49
45
@ Override
50
- public @ NotNull Visibility getWantedVisibility () {
51
- return this .visibility ;
52
- }
53
-
54
- @ Override
55
- public void update (ToastManager toastManager , long currentTime ) {
56
- if (this .firstRender == 0 ) {
57
- return ;
58
- }
59
-
60
- if (currentTime - this .firstRender >= 5000.0 * toastManager .getNotificationDisplayTimeMultiplier ()) {
61
- this .visibility = Visibility .HIDE ;
62
- }
63
- }
64
-
65
- @ Override
66
- public void render (GuiGraphics graphics , Font font , long currentTime ) {
46
+ public @ NotNull Visibility render (GuiGraphics graphics , ToastComponent toastComponent , long currentTime ) {
67
47
if (this .firstRender == 0 ) {
68
48
if (this == queuedToast ) {
69
49
queuedToast = null ;
@@ -75,12 +55,14 @@ public void render(GuiGraphics graphics, Font font, long currentTime) {
75
55
}
76
56
77
57
// resource, x, y, z, ?, ?, width, height, width, height
78
- graphics .blit (RenderType ::guiTextured , BACKGROUND_IMAGE , 0 , 0 , 0 , 0.0f , 0 , this .width (), this .height (), this .width (), this .height ());
58
+ graphics .blit (BACKGROUND_IMAGE , 0 , 0 , 0 , 0.0f , 0.0f , this .width (), this .height (), this .width (), this .height ());
59
+
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 );
79
62
80
- graphics .blit ( RenderType :: guiTextured , MOD_ICON , 2 , 2 , 0 , 0.0f , 0 , 8 , 8 , 8 , 8 );
81
- graphics .blit ( RenderType :: guiTextured , this .icon , 8 , 8 , 0 , 0.0f , 0 , 16 , 16 , 16 , 16 );
63
+ graphics .drawString ( toastComponent . getMinecraft (). font , this . title , 30 , 7 , 0x5f3315 , false );
64
+ graphics .drawString ( toastComponent . getMinecraft (). font , this .description , 30 , 18 , - 16777216 , false );
82
65
83
- graphics .drawString (Minecraft .getInstance ().font , this .title , 30 , 7 , 0x5f3315 , false );
84
- graphics .drawString (Minecraft .getInstance ().font , this .description , 30 , 18 , -16777216 , false );
66
+ return currentTime - this .firstRender >= 5000.0 * toastComponent .getNotificationDisplayTimeMultiplier () ? Toast .Visibility .HIDE : Toast .Visibility .SHOW ;
85
67
}
86
68
}
0 commit comments