1
1
package com .github .franckyi .guapi .api ;
2
2
3
3
import com .mojang .blaze3d .systems .RenderSystem ;
4
- import com .mojang .blaze3d .vertex .PoseStack ;
5
4
import net .minecraft .client .Minecraft ;
6
5
import net .minecraft .client .gui .Font ;
7
- import net .minecraft .client .gui .GuiComponent ;
6
+ import net .minecraft .client .gui .GuiGraphics ;
8
7
import net .minecraft .client .renderer .texture .TextureAtlasSprite ;
9
8
import net .minecraft .network .chat .Component ;
10
9
import net .minecraft .resources .ResourceLocation ;
@@ -30,62 +29,58 @@ public static int getFontWidth(Component text) {
30
29
return font ().width (text );
31
30
}
32
31
33
- public static void drawString (PoseStack matrices , Component text , float x , float y , int color , boolean shadow ) {
34
- if (shadow ) {
35
- font ().drawShadow (matrices , text , x , y , color );
36
- } else {
37
- font ().draw (matrices , text , x , y , color );
38
- }
32
+ public static void drawString (GuiGraphics guiGraphics , Component text , float x , float y , int color , boolean shadow ) {
33
+ guiGraphics .drawString (font (), text , (int ) x , (int ) y , color , shadow );
39
34
}
40
35
41
- public static void fillRectangle (PoseStack matrices , int x0 , int y0 , int x1 , int y1 , int color ) {
42
- GuiComponent .fill (matrices , x0 , y0 , x1 , y1 , color );
36
+ public static void fillRectangle (GuiGraphics guiGraphics , int x0 , int y0 , int x1 , int y1 , int color ) {
37
+ guiGraphics .fill (x0 , y0 , x1 , y1 , color );
43
38
}
44
39
45
- public static void drawVLine (PoseStack matrices , int x , int y0 , int y1 , int color ) {
46
- fillRectangle (matrices , x , y0 , x + 1 , y1 , color );
40
+ public static void drawVLine (GuiGraphics guiGraphics , int x , int y0 , int y1 , int color ) {
41
+ fillRectangle (guiGraphics , x , y0 , x + 1 , y1 , color );
47
42
}
48
43
49
- public static void drawHLine (PoseStack matrices , int y , int x0 , int x1 , int color ) {
50
- fillRectangle (matrices , x0 , y , x1 , y + 1 , color );
44
+ public static void drawHLine (GuiGraphics guiGraphics , int y , int x0 , int x1 , int color ) {
45
+ fillRectangle (guiGraphics , x0 , y , x1 , y + 1 , color );
51
46
}
52
47
53
- public static void drawRectangle (PoseStack matrices , int x0 , int y0 , int x1 , int y1 , int color ) {
54
- drawHLine (matrices , y0 , x0 , x1 - 1 , color );
55
- drawVLine (matrices , x1 - 1 , y0 , y1 - 1 , color );
56
- drawHLine (matrices , y1 - 1 , x1 , x0 + 1 , color );
57
- drawVLine (matrices , x0 , y1 , y0 + 1 , color );
48
+ public static void drawRectangle (GuiGraphics guiGraphics , int x0 , int y0 , int x1 , int y1 , int color ) {
49
+ drawHLine (guiGraphics , y0 , x0 , x1 - 1 , color );
50
+ drawVLine (guiGraphics , x1 - 1 , y0 , y1 - 1 , color );
51
+ drawHLine (guiGraphics , y1 - 1 , x1 , x0 + 1 , color );
52
+ drawVLine (guiGraphics , x0 , y1 , y0 + 1 , color );
58
53
}
59
54
60
- public static void drawTexture (PoseStack matrices , ResourceLocation id , int x , int y , int width , int height , int imageX , int imageY , int imageWidth , int imageHeight ) {
55
+ public static void drawTexture (GuiGraphics guiGraphics , ResourceLocation id , int x , int y , int width , int height , int imageX , int imageY , int imageWidth , int imageHeight ) {
61
56
RenderSystem .setShaderTexture (0 , id );
62
57
RenderSystem .enableBlend ();
63
58
RenderSystem .setShaderColor (1.0F , 1.0F , 1.0F , 1.0F );
64
59
RenderSystem .defaultBlendFunc ();
65
60
RenderSystem .enableDepthTest ();
66
- GuiComponent .blit (matrices , x , y , 0 , imageX , imageY , width , height , imageWidth , imageHeight );
61
+ guiGraphics .blit (id , x , y , 0 , imageX , imageY , width , height , imageWidth , imageHeight );
67
62
}
68
63
69
- public static void drawSprite (PoseStack matrices , TextureAtlasSprite sprite , int x , int y , int imageWidth , int imageHeight ) {
64
+ public static void drawSprite (GuiGraphics guiGraphics , TextureAtlasSprite sprite , int x , int y , int imageWidth , int imageHeight ) {
70
65
RenderSystem .setShaderTexture (0 , sprite .atlasLocation ());
71
66
RenderSystem .setShaderColor (1.0F , 1.0F , 1.0F , 1.0F );
72
- GuiComponent .blit (matrices , x , y , 0 , imageWidth , imageHeight , sprite );
67
+ guiGraphics .blit (x , y , 0 , imageWidth , imageHeight , sprite );
73
68
}
74
69
75
- public static void drawTooltip (PoseStack matrices , List <Component > text , int x , int y ) {
76
- mc (). screen . renderComponentTooltip (matrices , text , x , y );
70
+ public static void drawTooltip (GuiGraphics guiGraphics , List <Component > text , int x , int y ) {
71
+ guiGraphics . renderComponentTooltip (font () , text , x , y );
77
72
}
78
73
79
- public static void drawTooltip (PoseStack matrices , ItemStack itemStack , int x , int y ) {
80
- mc (). screen . renderComponentTooltip (matrices ,
74
+ public static void drawTooltip (GuiGraphics guiGraphics , ItemStack itemStack , int x , int y ) {
75
+ guiGraphics . renderComponentTooltip (font () ,
81
76
itemStack .getTooltipLines (Minecraft .getInstance ().player , TooltipFlag .Default .NORMAL ), x , y );
82
77
}
83
78
84
- public static void drawItem (PoseStack matrices , ItemStack itemStack , int x , int y ) {
85
- mc (). getItemRenderer (). renderAndDecorateFakeItem ( matrices , itemStack , x , y );
79
+ public static void drawItem (GuiGraphics guiGraphics , ItemStack itemStack , int x , int y ) {
80
+ guiGraphics . renderFakeItem ( itemStack , x , y );
86
81
}
87
82
88
- public static void drawItemDecorations (PoseStack matrices , ItemStack itemStack , int x , int y ) {
89
- mc (). getItemRenderer (). renderGuiItemDecorations ( matrices , font (), itemStack , x , y );
83
+ public static void drawItemDecorations (GuiGraphics guiGraphics , ItemStack itemStack , int x , int y ) {
84
+ guiGraphics . renderItemDecorations ( font (), itemStack , x , y );
90
85
}
91
86
}
0 commit comments