4444import net .minecraft .client .renderer .MultiBufferSource ;
4545import net .minecraft .core .registries .BuiltInRegistries ;
4646import net .minecraft .network .chat .Component ;
47+ import net .minecraft .network .chat .MutableComponent ;
4748import net .minecraft .resources .ResourceLocation ;
4849import net .minecraft .tags .TagKey ;
4950import net .minecraft .util .FormattedCharSequence ;
@@ -67,20 +68,22 @@ public ClientStructureMemberBlockTooltip(StructureMultiblockMemberBlockItem.Tool
6768
6869 StructureMemberMode mode = data .mode ();
6970
70- lines .add (new ComponentLine (MIText .StructureMultiblockMemberTooltipMode .text (mode .text ())));
71+ lines .add (new ComponentLine (MIText .StructureMultiblockMemberTooltipMode .text (mode .text ().withStyle (MITooltips .HIGHLIGHT_STYLE ))
72+ .withStyle (MITooltips .DEFAULT_STYLE )));
7173
7274 if (mode == StructureMemberMode .VARIABLE ) {
7375 String name = data .name ();
7476 if (name != null && !name .isEmpty ()) {
75- lines .add (new ComponentLine (MIText .StructureMultiblockMemberTooltipVariableName .text (name )));
77+ lines .add (new ComponentLine (MIText .StructureMultiblockMemberTooltipVariableName
78+ .text (Component .literal (name ).withStyle (MITooltips .HIGHLIGHT_STYLE )).withStyle (MITooltips .DEFAULT_STYLE )));
7679 }
7780 }
7881
7982 if (mode == StructureMemberMode .SIMPLE || mode == StructureMemberMode .HATCH ) {
8083 BlockState preview = data .preview ();
8184 if (preview != null && !preview .isAir ()) {
8285 ItemStack previewStack = preview .getBlock ().asItem ().getDefaultInstance ();
83- lines .add (new IconsLine (MIText .StructureMultiblockMemberTooltipPreview .text ().append (" " ),
86+ lines .add (new IconsLine (MIText .StructureMultiblockMemberTooltipPreview .text ().append (" " ). withStyle ( MITooltips . DEFAULT_STYLE ) ,
8487 List .of (new IconsLine .StackEntry (previewStack )), 6 ));
8588 }
8689
@@ -105,14 +108,16 @@ public ClientStructureMemberBlockTooltip(StructureMultiblockMemberBlockItem.Tool
105108 }
106109 }
107110 if (!members .isEmpty ()) {
108- lines .add (new IconsLine (MIText .StructureMultiblockMemberTooltipMembers .text ().append (" " ), members , 6 ));
111+ lines .add (new IconsLine (MIText .StructureMultiblockMemberTooltipMembers .text ().append (" " ).withStyle (MITooltips .DEFAULT_STYLE ),
112+ members , 6 ));
109113 }
110114 }
111115
112116 if (mode == StructureMemberMode .HATCH ) {
113117 MachineCasing casing = data .casing ();
114118 if (casing != null ) {
115- lines .add (new MachineCasingLine (MIText .StructureMultiblockMemberTooltipCasing .text ().append (" " ), casing ));
119+ lines .add (new MachineCasingLine (MIText .StructureMultiblockMemberTooltipCasing .text ().append (" " ).withStyle (MITooltips .DEFAULT_STYLE ),
120+ casing ));
116121 }
117122
118123 HatchFlags hatchFlags = data .hatchFlags ();
@@ -123,7 +128,8 @@ public ClientStructureMemberBlockTooltip(StructureMultiblockMemberBlockItem.Tool
123128 hatches .add (new IconsLine .HatchEntry (hatchType ));
124129 }
125130 }
126- lines .add (new IconsLine (MIText .StructureMultiblockMemberTooltipHatches .text ().append (" " ), hatches , 9 ));
131+ lines .add (new IconsLine (MIText .StructureMultiblockMemberTooltipHatches .text ().append (" " ).withStyle (MITooltips .DEFAULT_STYLE ),
132+ hatches , 9 ));
127133 }
128134 }
129135 }
@@ -180,16 +186,16 @@ default void renderText(Font font, int x, int y, Matrix4f matrix, MultiBufferSou
180186 }
181187 }
182188
183- private record ComponentLine (@ Nullable Component label , Component text ) implements Line {
184- public ComponentLine (Component text ) {
189+ private record ComponentLine (@ Nullable MutableComponent label , MutableComponent text ) implements Line {
190+ public ComponentLine (MutableComponent text ) {
185191 this (null , text );
186192 }
187193
188194 // 200 is the max width used by most tooltips
189195 private static final int MAX_WIDTH = 200 ;
190196
191197 private Component fullText () {
192- return label == null ? text : label .copy (). append (text );
198+ return label == null ? text : label .append (text );
193199 }
194200
195201 private int labelWidth (Font font ) {
@@ -221,7 +227,7 @@ public void renderText(Font font, int x, int y, Matrix4f matrix, MultiBufferSour
221227 }
222228 }
223229
224- private record IconsLine (Component label , List <Entry > entries , int maxToDisplay ) implements Line {
230+ private record IconsLine (MutableComponent label , List <Entry > entries , int maxToDisplay ) implements Line {
225231
226232 @ Override
227233 public int height (Font font ) {
@@ -250,7 +256,7 @@ public void renderText(Font font, int x, int y, Matrix4f matrix, MultiBufferSour
250256 font .drawInBatch (label , x , y + 5 , -1 , true , matrix , buffer , Font .DisplayMode .NORMAL , 0 , 0xF000F0 );
251257
252258 if (entries .size () > maxToDisplay ) {
253- font .drawInBatch (Component .literal ("+ ..." ).withStyle (MITooltips .DEFAULT_STYLE ), x + (18 * maxToDisplay ) + 2 + font .width (label ),
259+ font .drawInBatch (Component .literal ("+ ..." ).withStyle (MITooltips .HIGHLIGHT_STYLE ), x + (18 * maxToDisplay ) + 2 + font .width (label ),
254260 y + 5 , -1 ,
255261 true , matrix , buffer ,
256262 Font .DisplayMode .NORMAL , 0 , 0xF000F0 );
@@ -283,7 +289,7 @@ public void renderImage(Font font, int x, int y, GuiGraphics graphics) {
283289
284290 graphics .pose ().pushPose ();
285291 graphics .pose ().translate (0 , 0 , 200 );
286- graphics .drawString (font , Component .literal ("#" ).withStyle (MITooltips .DEFAULT_STYLE ), x , y , 0xFFFFFF , true );
292+ graphics .drawString (font , Component .literal ("#" ).withStyle (MITooltips .HIGHLIGHT_STYLE ), x , y , 0xFFFFFF , true );
287293 graphics .pose ().popPose ();
288294 }
289295 }
@@ -317,8 +323,8 @@ public void renderImage(Font font, int x, int y, GuiGraphics graphics) {
317323 public void renderText (Font font , int x , int y , Matrix4f matrix , MultiBufferSource .BufferSource buffer ) {
318324 font .drawInBatch (label , x , y + 5 , -1 , true , matrix , buffer , Font .DisplayMode .NORMAL , 0 , 0xF000F0 );
319325
320- font .drawInBatch (casing .getDisplayName ().copy (). withStyle (MITooltips .DEFAULT_STYLE ), x + font .width (label ) + 20 , y + 5 , -1 , true , matrix , buffer , Font . DisplayMode . NORMAL , 0 ,
321- 0xF000F0 );
326+ font .drawInBatch (casing .getDisplayName ().withStyle (MITooltips .HIGHLIGHT_STYLE ), x + font .width (label ) + 20 , y + 5 , -1 , true , matrix ,
327+ buffer , Font . DisplayMode . NORMAL , 0 , 0xF000F0 );
322328 }
323329 }
324330}
0 commit comments