Data API Implementation


Would it be possible to add persistent custom data to items. And possibly some hooks for using the item. That way we could add special modifiers to the items such as %damage increase, frost attacks, … etc. But the idea is the programmer implements a custom data attribute and when an item is created we can attach one or more of these custom data attributes. Then when the item is used (attack an entity, or other use item events) it will automatically call the corresponding custom attribute. This would need to persist inside of the item data. I feel like this fits in similarly to how we will be able to customize the functionality of entities.

edit: Just to clarify, this is the entity system i was referring to:

edit2: Another page describing the component system:

Also does the Data API have hooks into the component entity system? (And has the entity component system been implemented?)



Make a custom DataManipulator that extends AbstractDataManipulator, then wait for the implementation to handle custom data.

Your hooks are your events, then read the data and register your callbacks (or if you must, modify the event)

adding callbacks to events allows other plugins to co-operate with yours in order to change your actions if needed.

The Entity Component System hasn’t seen much love in a long while, but the Data API has elements that are similar.

I think the current plan is to hold off as Mojang themselves might be heading towards a ECS and the hope is by waiting it may be able to be compatible with sponges.


Excellent! Really looking forward to this as working with items as it is in bukkit is a nightmare.

Thanks for the information. Sad to hear about the entity component system, but I peaked around the code and it does seem to provide some better customization than bukkit already.

I heard Grum was working on some form of ECS? If this is true then entity customization should reach an entirely new level.


Sorry for the delay, after being sick and a certain amount of work needing to be done, I’ve finally managed to implement all the DataManipulators themselves, now all that is needed is writing all the DataUtils to make those data manipulators usable.

Yesterday, I implemented HealthData and tested, here’s a pic of using it in action!




Build Sponge: №445.


Do you know what exception is being thrown that is causing the error?

At a guess it will be because you are setting the current health above the maximum health, but I would have expected the DataManipulator to have capped the health at the maximum. It may be a bug.




The result is the same.
As if HealthData is not implemented.


What version of sponge are you using?


Sponge build 445.

In the console.



Ok I have no idea why it isn’t working, file a bug.

Shows that the healthUtil should be implemented.


Also sorry, I missed that you were using the latest version in your earlier post.


The individual methods such as getHealthData() and getFooData() from various entity interfaces aren’t implemented directly yet. The data implementation revolves around it working with the methods provided from DataHolder, in this case calling getData(HealthData.class).get() is valid to perform on any Living entity.

Another thing to note, while SpongeCommon may have certain things implemented, if the SpongeCommon reference isn’t updated for Sponge and SpongeVanilla, they won’t be made available.


Method setMaxHealt return error NoSuchMethodError


HealthData health = player.getData(HealthData.class).get();
double d = 40.0;