Fix NPE if banner had no patterns

This commit is contained in:
RednedEpic 2020-04-04 02:45:51 -05:00
parent 3aa7b2ddad
commit 79906fae0a

View file

@ -41,13 +41,14 @@ public class BannerBlockEntityTranslator extends BlockEntityTranslator {
List<Tag<?>> tags = new ArrayList<>();
ListTag patterns = tag.get("Patterns");
List<com.nukkitx.nbt.tag.CompoundTag> tagsList = new ArrayList<>();
for (com.github.steveice10.opennbt.tag.builtin.Tag patternTag : patterns.getValue()) {
tagsList.add(getPattern((CompoundTag) patternTag));
if (tag.contains("Patterns")) {
for (com.github.steveice10.opennbt.tag.builtin.Tag patternTag : patterns.getValue()) {
tagsList.add(getPattern((CompoundTag) patternTag));
}
com.nukkitx.nbt.tag.ListTag<com.nukkitx.nbt.tag.CompoundTag> bedrockPatterns =
new com.nukkitx.nbt.tag.ListTag<>("Patterns", com.nukkitx.nbt.tag.CompoundTag.class, tagsList);
tags.add(bedrockPatterns);
}
com.nukkitx.nbt.tag.ListTag<com.nukkitx.nbt.tag.CompoundTag> bedrockPatterns =
new com.nukkitx.nbt.tag.ListTag<>("Patterns", com.nukkitx.nbt.tag.CompoundTag.class, tagsList);
tags.add(bedrockPatterns);
if (tag.contains("CustomName")) {
tags.add(new StringTag("CustomName", (String) tag.get("CustomName").getValue()));
}