[Solved] Cast Sponge ItemStack to Minecraft ItemStack?

How do I cast a Sponge ItemStack to a Minecraft ItemStack? A forge mod I’m using has a method that requires a Minecraft ItemStack and I don’t know how to convert my Sponge ItemStack.

1 Like

Since you’ll have SpongeCommon available on the classpath, you can use ItemStackUtil.toNative

Sorry, I can’t seem to figure out how to implement ItemStackUtil or use it at all. IntelliJ has no autofill for ItemStackUtil for me, so I don’t think I have it?

You’ll need to add SpongeCommon/SpongeForge to your gradle dependencies.
This is what I’ve done in the past:

compile ('org.spongepowered:spongecommon:7.0.0-SNAPSHOT:dev') {
    exclude group: 'org.spongepowered', module: 'testplugins'
}

Weird, I used the Minecraft Module addon in IntelliJ and chose Sponge and Forge and it gave me the option to use SpongeForge. I guess it didn’t work but I’ll try adding this dependency now.

Yep, that worked. Thank you!