Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ public void addTagOrWrap(NBT tag) {
}
}

private static NBT tryUnwrap(NBTCompound tag) {
if (tag.tags.size() == 1) {
NBT unwrapped = tag.getTagOrNull("");
if (unwrapped != null) {
return unwrapped;
}
}
return tag; // failed to unwrap
}

// vanilla allows heterogeneous lists by wrapping the different
// tag types in a compound tag list
public List<? extends NBT> unwrapTags() {
Expand All @@ -146,12 +156,10 @@ public List<? extends NBT> unwrapTags() {
}
List<NBT> tags = new ArrayList<>(this.tags.size());
for (T tag : this.tags) {
if (!(tag instanceof NBTCompound) || ((NBTCompound) tag).size() != 1) {
continue;
}
NBT wrapped = ((NBTCompound) tag).getTagOrNull("");
if (wrapped != null) {
tags.add(wrapped);
if (tag instanceof NBTCompound) {
tags.add(tryUnwrap((NBTCompound) tag));
} else {
tags.add(tag);
}
}
return tags;
Expand Down