After upgrading a world to 24w09a or later, items that contain multiple entries of the same enchantment id lose enchantment data during the upgrade. Duplicate entries collapse into one, and at least one duplicate entry is discarded rather than preserved/combined.
Steps to Reproduce:
Create or open a world with cheats enabled in version 24w07a or earlier
Obtain an item with duplicate enchantment IDs (command I used below this list)
Upgrade the world to 26.1 Snapshot 5/1.21.11 (also occurs in any version after 24w09a) and open the same world to trigger upgrade.
Command used to obtain the item in the video: /give @s minecraft:diamond_sword{Enchantments:[{id:"minecraft:sharpness",lvl:1s},{id:"minecraft:sharpness",lvl:1s}]} 1
(The command is to obtain the item before 24w09a)
Observed behavior:
After upgrading to 24w09a+ / 1.21.11, or 26.1 Snapshot 5, the duplicate enchantment entries collapse into a single entry. One entry is discarded (the item no longer contains 2 entries for the same enchantment id).
Expected behavior:
World upgrade should be non-destructive and preserve enchantment data. If multiple entries exist with the same enchantment id, they should be combined by adding their levels rather than silently discarding one, to maintain compatibility and prevent data loss while keeping the new data format.
Videos below show before & after. (Sword with Sharpness I twice turned into a sword with Sharpness I)
Thank you for helping us improve Minecraft! We saved your files: