blob: fd058b0cc7c35a713fb6e8d9c8206c9d6c61dc03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
package me.shedaniel.rei.api;
import me.shedaniel.math.impl.PointHelper;
import me.shedaniel.rei.api.widgets.Tooltip;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import org.jetbrains.annotations.NotNull;
public interface TextRepresentable {
@NotNull
default Text asFormattedText() {
if (this instanceof EntryStack) {
Tooltip tooltip = ((EntryStack) this).getTooltip(PointHelper.ofMouse());
if (tooltip != null && !tooltip.getText().isEmpty())
return tooltip.getText().get(0);
}
return new LiteralText("");
}
@NotNull
default Text asFormatStrippedText() {
return new LiteralText(Formatting.strip(asFormattedText().getString()));
}
}
|