Fix invalid enchantment parsing

Fixes #2418
This commit is contained in:
KennyTV 2021-04-02 18:22:18 +02:00
parent 070c7f5808
commit 1251d43709
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B

View File

@ -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;