Skip to content

Commit

Permalink
Fix tooltips (dammit mojang)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Oct 1, 2024
1 parent 17691ba commit b31746d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/main/java/com/minelittlepony/common/client/gui/Tooltip.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,19 @@ default void appendNarrations(NarrationMessageBuilder narrationMsg) {
}

default CharSequence getString() {
StringBuilder builder = new StringBuilder();
getLines().forEach(line -> {
if (builder.length() > 0) {
builder.append('\n');
}
builder.append(line.getString());
});
return builder;
return getText().getString();
}

default Text getText() {
return stream().reduce(null, (a, b) -> a == null ? b : b == null ? a : a.copy().append("\n").append(b));
}

default Stream<Text> stream() {
return getLines().stream();
}

default net.minecraft.client.gui.tooltip.Tooltip toTooltip(IStyled<?> element) {
var tooltip = net.minecraft.client.gui.tooltip.Tooltip.of(Text.empty(), Text.literal(getString().toString()));
var tooltip = net.minecraft.client.gui.tooltip.Tooltip.of(getText(), getText());
((MixinTooltip)tooltip).setLines(stream().map(Text::asOrderedText).toList());
return tooltip;
}
Expand Down

0 comments on commit b31746d

Please sign in to comment.