From 1251d43709936b2d50875857e6c098a62492bf42 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Fri, 2 Apr 2021 18:22:18 +0200 Subject: [PATCH] Fix invalid enchantment parsing Fixes #2418 --- .../protocol1_13to1_12_2/packets/InventoryPackets.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java index f1af23167..fce0349e5 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java @@ -329,9 +329,10 @@ public class InventoryPackets { ListTag ench = tag.get("ench"); ListTag enchantments = new ListTag(CompoundTag.class); for (Tag enchEntry : ench) { - if (enchEntry instanceof CompoundTag) { + NumberTag idTag; + if (enchEntry instanceof CompoundTag && (idTag = ((CompoundTag) enchEntry).get("id")) != null) { CompoundTag enchantmentEntry = new CompoundTag(); - short oldId = ((NumberTag) ((CompoundTag) enchEntry).get("id")).asShort(); + short oldId = idTag.asShort(); String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId); if (newId == null) { newId = "viaversion:legacy/" + oldId;