11package net .vulkanmod .config .gui .widget ;
22
33import net .minecraft .client .Minecraft ;
4+ import net .minecraft .client .gui .Font ;
45import net .minecraft .client .renderer .RenderPipelines ;
6+ import net .minecraft .client .sounds .SoundManager ;
57import net .minecraft .network .chat .Component ;
68import net .minecraft .network .chat .FormattedText ;
79import net .minecraft .resources .Identifier ;
@@ -22,19 +24,26 @@ public ModIconWidget(FormattedText name, Identifier icon, int x0, int y0, int wi
2224 this .height = height ;
2325 }
2426
27+ @ Override
28+ public void playDownSound (SoundManager soundManager ) {
29+ }
30+
2531 public void render (double mX , double mY ) {
2632 int backgroundColor = ColorUtil .ARGB .multiplyAlpha (VGuiConstants .COLOR_BLACK , 0.6f );
2733 int width = this .width ;
2834 int height = this .height ;
2935 GuiRenderer .fill (this .x , this .y , this .x + width , this .y + height , backgroundColor );
3036
3137
32- int size = this .height - 4 ;
38+ int iconSize = this .height - 4 ;
3339 int iconX = this .x + 4 ;
34- int iconY = this .y + (height - size ) / 2 ;
35- GuiRenderer .guiGraphics .blit (RenderPipelines .GUI_TEXTURED , icon , iconX , iconY , 0f , 0f , size , size , size , size );
40+ int iconY = this .y + (height - iconSize ) / 2 ;
41+ GuiRenderer .guiGraphics .blit (RenderPipelines .GUI_TEXTURED , icon , iconX , iconY , 0f , 0f , iconSize , iconSize , iconSize , iconSize );
42+ Font textRenderer = Minecraft .getInstance ().font ;
43+
44+ int size = this .height ;
45+ int maxWidth = this .width - iconSize - 8 ;
3646
37- size = this .height ;
38- GuiRenderer .drawString (Minecraft .getInstance ().font , (Component ) this .name , this .x + 6 + size , this .y + this .height / 2 - 4 , 0xffffffff );
47+ GuiRenderer .drawScrollingString (textRenderer , (Component ) this .name , this .x + size + maxWidth / 2 + 3 , this .y + this .height / 2 - 4 , maxWidth - 4 , 0xffffffff );
3948 }
4049}
0 commit comments