From 59cb67da6ef28f2fa86876d33a8eb41c9bb53cd7 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Mon, 6 Jul 2020 15:06:01 +0200 Subject: [PATCH] Fix empty json in 1.14->1.13 items --- .../packets/BlockItemPackets1_14.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java index 4d2c4a37..c1a605f6 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java @@ -538,21 +538,19 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It CompoundTag display = tag.get("display"); if (((CompoundTag) tag.get("display")).get("Lore") instanceof ListTag) { ListTag lore = display.get("Lore"); - ListTag via = display.get(nbtTagName + "|Lore"); + ListTag via = display.remove(nbtTagName + "|Lore"); if (via != null) { display.put(ConverterRegistry.convertToTag("Lore", ConverterRegistry.convertToValue(via))); } else { for (Tag loreEntry : lore) { - if (loreEntry instanceof StringTag) { - ((StringTag) loreEntry).setValue( - ChatRewriter.jsonTextToLegacy( - ((StringTag) loreEntry).getValue() - ) - ); + if (!(loreEntry instanceof StringTag)) continue; + + String value = ((StringTag) loreEntry).getValue(); + if (value != null && !value.isEmpty()) { + ((StringTag) loreEntry).setValue(ChatRewriter.jsonTextToLegacy(value)); } } } - display.remove(nbtTagName + "|Lore"); } }