What are Properties for?

Hi there!

After digging a bit more in the SpongeAPI recently, I came across the Property interface. Can someone explain me what its usage is? What is the difference to the DataManipulator? I thought DataManipulators would represent block/entity/etc. data related stuff; why does a DataHolder has additional Properties?

Now, I’m not completely familiar with all parts of the Data API, but I’ll give my understanding.

Properties originally came from BlockState, where different blocks have different properties (e.g. ‘variant’ is a property of planks that describes the wood type [oak,beech,…])

The list of properties is finite for a block, and each property has a finite amount of valid values. So this makes properties well, a property of something.

A DataManipulator is different in the sense that they aren’t restricted to a set of predefined possible values, (e.g. JoinData, a DataManipulator, can have any value for the time).

I hope that is correct. If not, our data expert @gabizou can clarify.

OK a bit of clarification from gabizou:
A property is something that’s already provided and cannot change, it’s defined as unchanging.
Examples include the hardness of a block, or, in terms of inventory properties, where a slot can only contain a specific type of EquipmentType (e.g the helmet slot in the player’s inventory).

1 Like

Thanks, makes sense.