How can I get ItemType ID in Sponge 8.0 API?

How can I get ItemType ID in Sponge 8.0 API ?
String itemID = item.type().toString(); ← It display PickaxeItem[name=null]

I want it to display = “minecraft:wooden_pickaxe” but It show “PickaxeItem[name=null]”

Please help me.

Yep so in sponge toString is rarely what you want.

When it comes to ID’s you may find that something can have multiple ids and the context is what gives it the correct ID. So with ItemType it would be

itemType type;
type.key(RegistryTypes.ITEM_TYPE).formatted();

https://jd.spongepowered.org/spongeapi/8.0.0/org/spongepowered/api/registry/DefaultedRegistryValue.html#key(org.spongepowered.api.registry.DefaultedRegistryType)

https://jd.spongepowered.org/spongeapi/8.0.0/org/spongepowered/api/registry/RegistryTypes.html

1 Like

Thank for you care!

1 Like