blob: d88ae41b44ae0c0ff082fbae3752cdf3c6f16cfe (
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
26
27
28
29
30
31
32
|
package com.anthonyhilyard.iceberg.util;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.FormattedCharSink;
public class StringRecomposer implements FormattedCharSink
{
private StringBuilder builder = new StringBuilder();
private MutableComponent text = new TextComponent("").withStyle(Style.EMPTY);
@Override
public boolean accept(int index, Style style, int charCode)
{
builder.append(Character.toChars(charCode));
if (!style.equals(text.getStyle()))
{
text.append(new TextComponent(builder.toString()).withStyle(style));
builder.setLength(0);
}
return true;
}
public FormattedText getFormattedText()
{
text.append(new TextComponent(builder.toString()).withStyle(text.getStyle()));
return text;
}
}
|