From 723548580285eab39f65776ae0b3fefdb2271400 Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Sat, 14 Sep 2024 21:33:18 +0200 Subject: [PATCH] Cleanup enchantment conversion in 1.12->1.13 to match vanilla (#4147) Closes https://github.com/ViaVersion/ViaFabricPlus/issues/560 --- .../rewriter/ItemPacketRewriter1_13.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java index 12cff0a94..26119ee83 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java @@ -304,23 +304,15 @@ public class ItemPacketRewriter1_13 extends ItemRewriter enchantments = new ListTag<>(CompoundTag.class); for (CompoundTag enchEntry : ench) { - NumberTag idTag = enchEntry.getNumberTag("id"); - if (idTag == null) { - continue; - } + short oldId = enchEntry.getShort("id", (short) 0); CompoundTag enchantmentEntry = new CompoundTag(); - short oldId = idTag.asShort(); String newId = Protocol1_12_2To1_13.MAPPINGS.getOldEnchantmentsIds().get(oldId); if (newId == null) { newId = "viaversion:legacy/" + oldId; } enchantmentEntry.putString("id", newId); - - NumberTag levelTag = enchEntry.getNumberTag("lvl"); - if (levelTag != null) { - enchantmentEntry.putShort("lvl", levelTag.asShort()); - } + enchantmentEntry.putShort("lvl", enchEntry.getShort("lvl", (short) 0)); enchantments.add(enchantmentEntry); } @@ -589,10 +581,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter