Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException when setting DataComponentTypes.ITEM_MODEL on an item #11688

Closed
xikage opened this issue Nov 30, 2024 · 0 comments
Closed
Assignees
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. version: 1.21.3 Game version 1.21.3

Comments

@xikage
Copy link

xikage commented Nov 30, 2024

Expected behavior

I'm trying to set a model on an item using the new component API, specifically DataComponentTypes.ITEM_MODEL.

I would expect it to set the component

Observed/Actual behavior

Using the new paper component api for ITEM_MODEL causes the following ClassCastException error to happen instead of setting the component:

[22:46:19 WARN]: java.lang.ClassCastException: class net.kyori.adventure.key.KeyImpl cannot be cast to class org.bukkit.NamespacedKey (net.kyori.adventure.key.KeyImpl and org.bukkit.NamespacedKey are in unnamed module of loader java.net.URLClassLoader @7e32c033)
[22:46:19 WARN]:        at io.papermc.paper.datacomponent.ComponentAdapter.toVanilla(ComponentAdapter.java:23)
[22:46:19 WARN]:        at org.bukkit.craftbukkit.inventory.CraftItemStack.setDataInternal(CraftItemStack.java:591)
[22:46:19 WARN]:        at org.bukkit.craftbukkit.inventory.CraftItemStack.setData(CraftItemStack.java:579)
[22:46:19 WARN]:        at org.bukkit.inventory.ItemStack.setData(ItemStack.java:1248)

Steps/models to reproduce

Run the following code:

ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
Key key = Key.key("minecraft", "items/any_item_model");
item.setData(DataComponentTypes.ITEM_MODEL, key);

Plugin and Datapack List

Plugins (1): TestPlugin

Paper version

This server is running Paper version 1.21.3-74-master@47f2071 (2024-11-29T16:26:16Z) (Implementing API version 1.21.3-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21.3-67-d38624b (MC: 1.21.3)

Other

The error seems pretty straight-forward idk

@papermc-sniffer papermc-sniffer bot added the version: 1.21.3 Game version 1.21.3 label Nov 30, 2024
@kennytv kennytv added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed status: needs triage labels Nov 30, 2024
@kennytv kennytv self-assigned this Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. version: 1.21.3 Game version 1.21.3
Projects
None yet
Development

No branches or pull requests

2 participants