Skip to content

Commit 6cda560

Browse files
committed
Adjust text colors to be more consistent with other tooltips
1 parent 93aeb3b commit 6cda560

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

src/client/java/aztech/modern_industrialization/items/client/ClientStructureMemberBlockTooltip.java

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import net.minecraft.client.renderer.MultiBufferSource;
4545
import net.minecraft.core.registries.BuiltInRegistries;
4646
import net.minecraft.network.chat.Component;
47+
import net.minecraft.network.chat.MutableComponent;
4748
import net.minecraft.resources.ResourceLocation;
4849
import net.minecraft.tags.TagKey;
4950
import 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
}

src/main/java/aztech/modern_industrialization/blocks/structure/member/StructureMemberMode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import aztech.modern_industrialization.MIText;
2727
import java.util.Locale;
28-
import net.minecraft.network.chat.Component;
28+
import net.minecraft.network.chat.MutableComponent;
2929
import net.minecraft.util.StringRepresentable;
3030

3131
public enum StructureMemberMode implements StringRepresentable {
@@ -40,11 +40,11 @@ public enum StructureMemberMode implements StringRepresentable {
4040
this.text = text;
4141
}
4242

43-
public Component textInfo() {
43+
public MutableComponent textInfo() {
4444
return textInfo.text();
4545
}
4646

47-
public Component text() {
47+
public MutableComponent text() {
4848
return text.text();
4949
}
5050

0 commit comments

Comments
 (0)