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<>(); List<Tag<?>> tags = new ArrayList<>();
ListTag patterns = tag.get("Patterns"); ListTag patterns = tag.get("Patterns");
List<com.nukkitx.nbt.tag.CompoundTag> tagsList = new ArrayList<>(); List<com.nukkitx.nbt.tag.CompoundTag> tagsList = new ArrayList<>();
for (com.github.steveice10.opennbt.tag.builtin.Tag patternTag : patterns.getValue()) { if (tag.contains("Patterns")) {
tagsList.add(getPattern((CompoundTag) patternTag)); 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")) { if (tag.contains("CustomName")) {
tags.add(new StringTag("CustomName", (String) tag.get("CustomName").getValue())); tags.add(new StringTag("CustomName", (String) tag.get("CustomName").getValue()));
} }