PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.7k stars 2.27k forks source link

ItemStack.getEnchantments() is incompatible with "minecraft:stored_enchantments" component #11409

Closed Unnamed3 closed 5 days ago

Unnamed3 commented 5 days ago

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

Example video of bug reproduction : https://github.com/user-attachments/assets/9884b9ad-41c7-479f-a648-2500cd1bb3df

Plugin and Datapack List

> plugins
[19:52:17 INFO]: Server Plugins (1):
[19:52:17 INFO]: Bukkit Plugins:
[19:52:17 INFO]:  - AdvancedSilkTouch
> datapack list
[19:53:25 INFO]: There are 4 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [file/adventure_datapack (world)], [paper (built-in)]
[19:53:25 INFO]: There are no more data packs available

compileOnly "io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT"

Paper version

version [20:11:41 INFO]: Checking version, please wait... [20:11:41 INFO]: This server is running Paper version 1.21.1-82-master@1348e44 (2024-09-16T19:02:37Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT) You are running the latest version Previous version: 1.21.1-81-13a2395 (MC: 1.21.1)

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 version paper-1.21.1-76 released 10 minutes before this issue was posted.

electronicboy commented 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

Unnamed3 commented 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

Thank you, I'll dig into that