Move FormattedText addition into a combined function

This commit is contained in:
altrisi committed 2020-12-15 10:00:09 +01:00
1 parent 6dfd64027d
commit a81b549360
2 files changed
+31 -18

No files matched your search

+1 -7
View File
@@ -4,8 +4,6 @@ import carpet.script.exception.InternalExpressionException;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import net.minecraft.nbt.Tag;
import net.minecraft.text.BaseText;
import net.minecraft.text.LiteralText;
import java.util.ArrayList;
import java.util.List;
@@ -83,11 +81,7 @@ public abstract class Value implements Comparable<Value>, Cloneable
String lstr = this.getString();
if (o instanceof FormattedTextValue)
{
if (lstr == null)
return ((FormattedTextValue) o).clone();
BaseText newText = new LiteralText(lstr);
newText.append(((FormattedTextValue) o).getText().shallowCopy());
return new FormattedTextValue(newText);
return FormattedTextValue.combine(this, o);
}
if (lstr == null) // null
return new StringValue(o.getString());