Closed Unnamed3 closed 5 days ago
stored_enchantments are not enchantments on the item, see https://jd.papermc.io/paper/1.21.1/org/bukkit/inventory/meta/EnchantmentStorageMeta.html
stored_enchantments are not enchantments on the item, see https://jd.papermc.io/paper/1.21.1/org/bukkit/inventory/meta/EnchantmentStorageMeta.html
Thank you, I'll dig into that
Expected behavior
ItemStack.getEnchantments().toString() returns {CraftEnchantment[minecraft:silk_touch]=1} for a silk touch enchanted book taken from creative inventory.
Observed/Actual behavior
ItemStack.getEnchantments().toString() returns {} for a silk touch enchanted book taken from creative inventory.
Steps/models to reproduce
Get an enchanted book from creative inventory and try to call getEnchantments for this ItemStack. The function returns an empty set.
Get an enchanted tool and try to call getEnchantments for this ItemStack. The function returns the enchantments as expected.
Example video of bug reproduction : https://github.com/user-attachments/assets/9884b9ad-41c7-479f-a648-2500cd1bb3df
Plugin and Datapack List
compileOnly "io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT"
Paper version
Other
It seems that "minecraft:stored_enchantments" component name causes the ItemStack.getEnchantments() method to fail, as the functions works as expected with "minecraft:enchantments" method. To get the working custom enchanted book shown in video (with "minecraft:enchantments" component, and light blue text color), you can use this command :
/give @s enchanted_book[enchantments={levels:{silk_touch:1}}]
The video was recorded on version
paper-1.21.1-76
but the issue is still reproducible in versionpaper-1.21.1-76
released 10 minutes before this issue was posted.