Skip to content

Commit

Permalink
Fix crash when rendering a tooltip with no text
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Oct 6, 2024
1 parent b31746d commit 4202842
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.google.common.base.MoreObjects;
import com.google.common.base.Splitter;
import com.minelittlepony.common.client.gui.style.IStyled;
import com.minelittlepony.common.mixin.MixinTooltip;
Expand All @@ -14,6 +15,7 @@
import net.minecraft.client.gui.Narratable;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.screen.narration.NarrationPart;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.MutableText;
import net.minecraft.text.StringVisitable;
import net.minecraft.text.Style;
Expand All @@ -34,7 +36,7 @@ default CharSequence getString() {
}

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

default Stream<Text> stream() {
Expand Down

0 comments on commit 4202842

Please sign in to comment.