Skip to content

Commit

Permalink
Add sanity check in 1.13->1.12 enchantment handler
Browse files Browse the repository at this point in the history
Closes #2908
  • Loading branch information
kennytv committed Jun 3, 2022
1 parent c2ae3df commit 9da206e
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,17 @@ private void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnch) {
for (Tag enchantmentEntryTag : enchantments.clone()) {
CompoundTag enchantmentEntry = (CompoundTag) enchantmentEntryTag;
Tag idTag = enchantmentEntry.get("id");
if (!(idTag instanceof StringTag)) continue;
if (!(idTag instanceof StringTag)) {
continue;
}

String newId = (String) idTag.getValue();
int levelValue = ((NumberTag) enchantmentEntry.get("lvl")).asInt();
NumberTag levelTag = enchantmentEntry.get("lvl");
if (levelTag == null) {
continue;
}

int levelValue = levelTag.asInt();
short level = levelValue < Short.MAX_VALUE ? (short) levelValue : Short.MAX_VALUE;

String mappedEnchantmentId = enchantmentMappings.get(newId);
Expand Down

0 comments on commit 9da206e

Please sign in to comment.