More sanity checks in legacy enchantment handling

Fixes #336
This commit is contained in:
KennyTV 2021-03-01 18:25:31 +01:00
parent 70a10132d0
commit a8de222bc2
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B

View File

@ -24,7 +24,10 @@ public class LegacyEnchantmentRewriter {
ListTag remappedEnchantments = new ListTag(nbtTagName + "|" + key, CompoundTag.class);
List<Tag> lore = new ArrayList<>();
for (Tag enchantmentEntry : enchantments.clone()) {
Short newId = (Short) ((CompoundTag) enchantmentEntry).get("id").getValue();
Tag idTag = ((CompoundTag) enchantmentEntry).get("id");
if (idTag == null) continue;
short newId = ((Number) idTag.getValue()).shortValue();
String enchantmentName = enchantmentMappings.get(newId);
if (enchantmentName != null) {
enchantments.remove(enchantmentEntry);