Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Saving data


RaphGamingz
 Share

Recommended Posts

Just now, RaphGamingz said:

How do i save a capability on a item that extends ICapabilitySerializable. 

Making an item class extend ICapabilitySerializable does not make much sense. To save data on an item via a capability you make a capability like normal and then attach it by overriding initCapabilities.

 

1 minute ago, RaphGamingz said:

How do i save data on a player, like skills and make it increase every time a player breaks a block

Make a capability and attach it to the player using AttachCapabilitiesEvent<Entity>.

Link to comment
Share on other sites

Does it save when a player leaves and does it save when the world is closed

4 minutes ago, diesieben07 said:

Make a capability and attach it to the player using AttachCapabilitiesEvent<Entity>.

 

6 minutes ago, diesieben07 said:

Making an item class extend ICapabilitySerializable does not make much sense. To save data on an item via a capability you make a capability like normal and then attach it by overriding initCapabilities.

will the capability have read and write, getCapability and what will the capability class extend or implement?

Link to comment
Share on other sites

9 minutes ago, RaphGamingz said:

oes it save when a player leaves and does it save when the world is closed

Yes, it's saved with the normal player data.

 

9 minutes ago, RaphGamingz said:

will the capability have read and write

If you implement INBTSerializable on the ICapabilityProvider then yes, the provider can save to NBT.

 

10 minutes ago, RaphGamingz said:

getCapability

Yes, ICapabilityProvider has that method.

 

10 minutes ago, RaphGamingz said:

what will the capability class extend or implement? 

That is completely up to you. It does not have to extend or implement anything.

Link to comment
Share on other sites

6 minutes ago, RaphGamingz said:

so i have a item class that extends item implements INBTSerializable, ICapabilityProvider

No. Again:

31 minutes ago, diesieben07 said:

Making an item class extend ICapabilitySerializable does not make much sense. To save data on an item via a capability you make a capability like normal and then attach it by overriding initCapabilities.

 

Link to comment
Share on other sites

For attached capabilties (AttachCapabilitiesEvent) or item capabilities in general (initCapabilities) the ICapabilityProvider needs to implement INBTSerializable to store data, yes.

For capabilities exposed directly by entities or tile entities those need to be saved "manually" by the owning (tile) entity.

Link to comment
Share on other sites

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.