@@ -84,7 +84,7 @@ public ClientStructureMemberBlockTooltip(StructureMultiblockMemberBlockItem.Tool
8484 if (preview != null && !preview .isAir ()) {
8585 ItemStack previewStack = preview .getBlock ().asItem ().getDefaultInstance ();
8686 lines .add (new IconsLine (MIText .StructureMultiblockMemberTooltipPreview .text ().append (" " ).withStyle (MITooltips .DEFAULT_STYLE ),
87- List .of (new IconsLine .StackEntry (previewStack )), 6 ));
87+ List .of (new IconsLine .StackEntry (previewStack )), 6 , previewStack . getHoverName (). copy () ));
8888 }
8989
9090 List <IconsLine .Entry > members = new ArrayList <>();
@@ -109,7 +109,7 @@ public ClientStructureMemberBlockTooltip(StructureMultiblockMemberBlockItem.Tool
109109 }
110110 if (!members .isEmpty ()) {
111111 lines .add (new IconsLine (MIText .StructureMultiblockMemberTooltipMembers .text ().append (" " ).withStyle (MITooltips .DEFAULT_STYLE ),
112- members , 6 ));
112+ members , 6 , null ));
113113 }
114114 }
115115
@@ -129,7 +129,7 @@ public ClientStructureMemberBlockTooltip(StructureMultiblockMemberBlockItem.Tool
129129 }
130130 }
131131 lines .add (new IconsLine (MIText .StructureMultiblockMemberTooltipHatches .text ().append (" " ).withStyle (MITooltips .DEFAULT_STYLE ),
132- hatches , 9 ));
132+ hatches , 9 , null ));
133133 }
134134 }
135135 }
@@ -227,7 +227,7 @@ public void renderText(Font font, int x, int y, Matrix4f matrix, MultiBufferSour
227227 }
228228 }
229229
230- private record IconsLine (MutableComponent label , List <Entry > entries , int maxToDisplay ) implements Line {
230+ private record IconsLine (MutableComponent label , List <Entry > entries , int maxToDisplay , @ Nullable MutableComponent suffix ) implements Line {
231231
232232 @ Override
233233 public int height (Font font ) {
@@ -237,7 +237,8 @@ public int height(Font font) {
237237 @ Override
238238 public int width (Font font ) {
239239 return font .width (label ) + (18 * Math .min (maxToDisplay , entries .size ()))
240- + (entries .size () > maxToDisplay ? font .width (Component .literal ("+ ..." )) : 0 );
240+ + (entries .size () > maxToDisplay ? font .width (Component .literal ("+ ..." )) : 0 )
241+ + (suffix != null ? font .width (suffix ) : 0 );
241242 }
242243
243244 @ Override
@@ -254,12 +255,20 @@ public void renderImage(Font font, int x, int y, GuiGraphics graphics) {
254255 @ Override
255256 public void renderText (Font font , int x , int y , Matrix4f matrix , MultiBufferSource .BufferSource buffer ) {
256257 font .drawInBatch (label , x , y + 5 , -1 , true , matrix , buffer , Font .DisplayMode .NORMAL , 0 , 0xF000F0 );
258+ x += font .width (label );
257259
258260 if (entries .size () > maxToDisplay ) {
259- font .drawInBatch (Component .literal ("+ ..." ).withStyle (MITooltips .HIGHLIGHT_STYLE ), x + (18 * maxToDisplay ) + 2 + font .width (label ),
260- y + 5 , -1 ,
261- true , matrix , buffer ,
262- Font .DisplayMode .NORMAL , 0 , 0xF000F0 );
261+ x += (18 * maxToDisplay ) + 2 ;
262+ Component moreText = Component .literal ("+ ..." ).withStyle (MITooltips .HIGHLIGHT_STYLE );
263+ font .drawInBatch (moreText , x , y + 5 , -1 , true , matrix , buffer , Font .DisplayMode .NORMAL , 0 , 0xF000F0 );
264+ x += font .width (moreText );
265+ } else {
266+ x += (18 * entries .size ()) + 2 ;
267+ }
268+
269+ if (suffix != null ) {
270+ font .drawInBatch (suffix .withStyle (MITooltips .HIGHLIGHT_STYLE ), x , y + 5 , -1 , true , matrix , buffer , Font .DisplayMode .NORMAL , 0 ,
271+ 0xF000F0 );
263272 }
264273 }
265274
0 commit comments