Jump to content

[1.19.4, ANSWERED] Capability or NBT for items?


LeeCrafts

Recommended Posts

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 by LeeCrafts
Link to comment
Share on other sites

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 

 

  • Thanks 1
Link to comment
Share on other sites

  • LeeCrafts changed the title to [1.19.4, ANSWERED] Capability or NBT for items?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.