Posted August 18, 20214 yr Hello, I'm trying to better understand capabilities and how they work. I see a lot of examples/tutorials for entities and tile entities but not much for itemstacks, at least from what I could find. I'm trying to make an itemstack store an entity and a sound event for my own item, I dunno if I can possibly do that any other way as well. Any where I could look as an example/guide, or just an explanation?
August 18, 20214 yr it's the same, the only thing that changes is you attach the capability to and ItemStack and not to an Entity/BlockEntity
August 20, 20214 yr Author On 8/18/2021 at 10:18 AM, Luis_ST said: it's the same, the only thing that changes is you attach the capability to and ItemStack and not to an Entity/BlockEntity Alright, so how would I go about about attaching it to my own item? There's an initcapabilites method in the item class that the bucket uses, so I'm assuming that? And how would I set things like soundevent and entity in the item class?
August 20, 20214 yr https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/#attaching-capabilities
August 20, 20214 yr Author 1 hour ago, Luis_ST said: https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/#attaching-capabilities I attached it to the item by using that event, it keeps crashing though saying that the sound event could be null. I did add a null check, but it still crashes. I'm a bit stumped on what to do IStaff Class: https://pastebin.com/NZs5dYdX Default Instance: https://pastebin.com/9cTvw6Kx Staff Storage: https://pastebin.com/N3UkfU2Y Staff Provider: https://pastebin.com/eAkDKtGd Staff Capability: https://pastebin.com/SUuqLJV4 Capability Handler: https://pastebin.com/qvrW6CCU
August 20, 20214 yr Author 5 hours ago, Luis_ST said: post the log Here's the log : https://pastebin.com/cZjzwYdu Here's also the crash report: https://pastebin.com/3VKZhuMC
August 20, 20214 yr okay first of all, you don't need an IStorage, just return and empty CompoundNBT, you should because the error occurs there inside of getCapability you need to check if it is your Capability and your serializeNBT and deserializeNBT methods in your StaffProvider are broken, add a serializeNBT & deserializeNBT to your DefaultStaffCapability and call them inside the method why did you add two providers to the ItemStack? you should also create a git repo because it is terrible to look at many classes when using pastebin
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.