Merge branch 'master' into 1.17

This commit is contained in:
gnembon committed 2021-04-21 18:42:50 -03:00
commit cd6827767a
10 files changed
+43 -39

No files matched your search

@@ -1122,7 +1122,7 @@ public class EntityValue extends Value
v = ((ListValue) v).getItems().get(0);
}
e.setCustomNameVisible(showName);
e.setCustomName(new LiteralText(v.getString()));
e.setCustomName(FormattedTextValue.getTextByValue(v));
});
put("persistence", (e, v) ->
@@ -54,7 +54,7 @@ public class FormattedTextValue extends StringValue
@Override
public boolean getBoolean() {
return text.getSiblings().size() > 0;
return !text.asString().isEmpty();
}
@Override
@@ -96,4 +96,8 @@ public class FormattedTextValue extends StringValue
return new FormattedTextValue(Text.Serializer.fromJson(serialized));
}
public static Text getTextByValue(Value value) {
return (value instanceof FormattedTextValue) ? ((FormattedTextValue) value).getText() : new LiteralText(value.getString());
}
}
@@ -571,13 +571,14 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
@Override
public Value get(Value value)
{
NbtPathArgumentType.NbtPath path = cachePath(value.getString());
String valString = value.getString();
NbtPathArgumentType.NbtPath path = cachePath(valString);
try
{
List<NbtElement> tags = path.get(getTag());
if (tags.size()==0)
return Value.NULL;
if (tags.size()==1)
if (tags.size()==1 && !valString.endsWith("[]"))
return NBTSerializableValue.decodeTag(tags.get(0));
return ListValue.wrap(tags.stream().map(NBTSerializableValue::decodeTag).collect(Collectors.toList()));
}