Posted May 29, 20232 yr As seen in the CrossbowItem class, an NBT boolean tag “Charged” is attached to crossbows. I have a custom item that extends CrossbowItem, and I want to attach other data in addition to the “Charged” tag. Should I use capabilities or NBTs? I am wondering if there are any significant advantages of using one over another for ItemStacks. Edited May 29, 20232 yr by LeeCrafts
May 29, 20232 yr Nice question you can use directly nbt or create a capability whats the deal NBT is data stored inside an internal database every time you recall data it has to create an NBT object and query the internal database to read or write data Capability is a java object loaded in memory it recall data from the item internally uses NBT but only query save/write data when changes are detected, capabilities keep loaded in memory until the item is stored or discarted if you just gonna store a simple number you gonna call one every 2 or 3 ticks like the ammunition/fuel count then no problem on using NBT directly but if you wanna doo complex thing that need to consult data every tick or worst as mi items that uses json system to display animations client side it gonna slowdown the computer this case is better to recall the data from the capability loaded in memory and the capability will take care of read/writing nbt thing only when changes are detected this gun was made animation in client side whit nbt in old 1.8 its choppy and skip badly frames this one was made in 1.12 whit a capability to query the data client side
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.