5
5
import net .minecraft .client .gui .Font ;
6
6
import net .minecraft .client .gui .GuiGraphics ;
7
7
import net .minecraft .client .gui .components .toasts .Toast ;
8
- import net .minecraft .client .gui .components .toasts .ToastManager ;
8
+ import net .minecraft .client .gui .components .toasts .ToastComponent ;
9
9
import net .minecraft .client .renderer .RenderType ;
10
10
import net .minecraft .network .chat .Component ;
11
11
import net .minecraft .resources .ResourceLocation ;
14
14
15
15
public class BaseToast implements Toast {
16
16
private long firstRender ;
17
- private Visibility visibility ;
18
17
19
18
protected Component title ;
20
19
protected Component description ;
@@ -28,47 +27,31 @@ protected BaseToast(Component title, Component description, @Nullable ResourceLo
28
27
this .description = description ;
29
28
30
29
this .icon = icon ;
31
-
32
- this .visibility = Visibility .SHOW ;
33
- }
34
-
35
- @ Override
36
- public @ NotNull Visibility getWantedVisibility () {
37
- return this .visibility ;
38
- }
39
-
40
- @ Override
41
- public void update (ToastManager toastManager , long currentTime ) {
42
- if (this .firstRender == 0 ) {
43
- return ;
44
- }
45
-
46
- if (currentTime - this .firstRender >= 5000.0 * toastManager .getNotificationDisplayTimeMultiplier ()) {
47
- this .visibility = Visibility .HIDE ;
48
- }
49
30
}
50
31
51
32
@ Override
52
- public void render (GuiGraphics graphics , Font font , long currentTime ) {
33
+ public @ NotNull Visibility render (GuiGraphics graphics , ToastComponent toastComponent , long currentTime ) {
53
34
if (this .firstRender == 0 ) {
54
35
this .onFirstRender ();
55
36
this .firstRender = currentTime ;
56
37
}
57
38
58
- // type, resource, x, y, ?, ?, width, height, width, height
59
- graphics .blit (RenderType :: guiTextured , BACKGROUND_IMAGE , 0 , 0 , 0.0f , 0 , this .width (), this .height (), this .width (), this .height ());
39
+ // resource, x, y, z , ?, ?, width, height, width, height
40
+ graphics .blit (BACKGROUND_IMAGE , 0 , 0 , 0.0f , 0.0f , this .width (), this .height (), this .width (), this .height ());
60
41
61
42
int x = 8 ;
62
43
63
44
if (this .icon != null ) {
64
45
x += 22 ;
65
46
66
- graphics .blit (RenderType :: guiTextured , MOD_ICON , 2 , 2 , 0.0f , 0 , 8 , 8 , 8 , 8 );
67
- graphics .blit (RenderType :: guiTextured , this .icon , 8 , 8 , 0.0f , 0 , 16 , 16 , 16 , 16 );
47
+ graphics .blit (MOD_ICON , 2 , 2 , 0.0f , 0.0f , 8 , 8 , 8 , 8 );
48
+ graphics .blit (this .icon , 8 , 8 , 0.0f , 0.0f , 16 , 16 , 16 , 16 );
68
49
}
69
50
70
- graphics .drawString (Minecraft .getInstance ().font , this .title , x , 7 , 0x5f3315 , false );
71
- graphics .drawString (Minecraft .getInstance ().font , this .description , x , 18 , -16777216 , false );
51
+ graphics .drawString (toastComponent .getMinecraft ().font , this .title , x , 7 , 0x5f3315 , false );
52
+ graphics .drawString (toastComponent .getMinecraft ().font , this .description , x , 18 , -16777216 , false );
53
+
54
+ return currentTime - this .firstRender >= 5000.0 * toastComponent .getNotificationDisplayTimeMultiplier () ? Toast .Visibility .HIDE : Toast .Visibility .SHOW ;
72
55
}
73
56
74
57
public void onFirstRender () {}
0 commit comments