Structure and Overview

Data Attributes includes an API package, located at com.github.clevernucleus.dataattributes.api and contains the following:

📂api
 ┣📂attribute
 ┃ ┣📄AdditionFunction.java interface
 ┃ ┣📄AttributeBehaviour.java enum
 ┃ ┣📄AdditionFunction.java interface
 ┃ ┣📄IAttribute.java interface
 ┃ ┣📄IAttributeFunction.java interface
 ┃ ┗📄IEntityAttributeModifier.java interface
 ┃
 ┣📂event
 ┃ ┣📂client
 ┃ ┃ ┗📄ClientSyncedEvent.java class
 ┃ ┃
 ┃ ┣📄EntityAttributeEvents.java class
 ┃ ┣📄MathClampEvent.java class
 ┃ ┗📄ServerSyncedEvent.java class
 ┃
 ┗📄API.java class

API Content

The following subsections detail every method/field in each java class located in the api package.

1. attribute.AdditionFunction.java

Modifiers and Type Method/Field and Description
double add(double current, double adding, double limit)
A functional interface equivalent to a TriFunction, used to add a layer of abstraction to function behaviours.

2. attribute.AttributeBehaviour.java

Modifiers and Type Method/Field and Description
public
static
final
AttributeBehaviour
FLAT
Flat/normal addition behaviour.
public
static
final
AttributeBehaviour
DIMINISHING
Diminishing addition behaviour.
public
byte
id()
Returns the byte id of the behaviour enum.
public
double
result(double current, double adding, double limit)
Returns the inputs through the correct function for the specific behaviour type.
public
static
AttributeBehaviour
fromId(byte id)
Takes a byte id and returns the corresponding behaviour type.

3. attribute.IAttribute.java

Modifiers and Type Method/Field and Description
double getDefaultValue()
Returns the attribute’s default value.
double getMinValue()
Returns the attribute’s minimum value.
double getMaxValue()
Returns the attribute’s maximum value.
double clamp(double value)
For EntityAttribute, returns the input. For ClampedEntityAttribute, returns a clamped value between the min and max.
String getTranslationKey()
Returns the attribute’s translation key (references a lang json name).
Collection<String> properties()
Returns an immutable collection of the properties’ keys attached to this attribute.
boolean hasProperty(String property)
Returns true if this attribute has the input property key; false if not, or if the input is null.
String getProperty(String property)
Returns this attribute’s property value assigned to the input property’s key. If it does not exist or is null, returns “”.
Collection<IAttributeFunction> functions()
Returns an immutable collection of the attribute functions attached to this attribute.

4. attribute.AttributeFunction.java

Modifiers and Type Method/Field and Description
Identifier attribute()
Returns the affected attribute’s registry key.
AttributeBehaviour behaviour()
Returns the affected attribute’s behaviour (if it uses flat or diminishing addition).
double multiplier()
Returns a multiplier applied to the resulting change in value (e.g. for every one point changed in the parent attribute).

5. attribute.IEntityAttributeModifier.java

Modifiers and Type Method/Field and Description
UUID getId()
Returns the modifier’s uuid.
String getName()
Returns the modifier’s name.
Operation getOperation()
Returns the modifier’s operation.
double getValue()
Returns the modifier’s (mutable) value.
void setValue(double value)
Sets the value of the modifier.

6. event.client.ClientSyncedEvent.java

Modifiers and Type Method/Field and Description
public
static
final
Event<Synced>
EVENT
Provides a hook to the client, AFTER it has received server-side packets and synced all Data Attribute’s relevant data, but BEFORE the player exists (i.e. during login).
public
interface
Synced {…}
Nested functional interface for EVENT .

7. event.EntityAttributeEvents.java

Modifiers and Type Method/Field and Description
public
static
final
Event<AddedPre>
MODIFIER_ADDED_PRE
Fired before an EntityAttributeModifier is added to an EntityAttributeInstance.
public
static
final
Event<AddedPost>
MODIFIER_ADDED_POST
Fired after an EntityAttributeModifier is added to an EntityAttributeInstance.
public
static
final
Event<RemovedPre>
MODIFIER_REMOVED_PRE
Fired before an EntityAttributeModifier is removed from an EntityAttributeInstance.
public
static
final
Event<RemovedPost>
MODIFIER_REMOVED_POST
Fired after an EntityAttributeModifier is removed from an EntityAttributeInstance.
public
interface
AddedPre {…}
Nested functional interface for MODIFIER_ADDED_PRE .
public
interface
AddedPost {…}
Nested functional interface for MODIFIER_ADDED_POST .
public
interface
RemovedPre {…}
Nested functional interface for MODIFIER_REMOVED_PRE .
public
interface
RemovedPost {…}
Nested functional interface for MODIFIER_REMOVED_POST .

8. event.MathClamp.java

Modifiers and Type Method/Field and Description
public
static
final
Event<Clamp>
EVENT
Fired on EntityAttribute#clamp and on ClampedEntityAttribute#clamp but before MathHelper#clamp is called.
public
interface
Clamp {…}
Nested functional interface for EVENT .

9. event.ServerSyncedEvent.java

Modifiers and Type Method/Field and Description
public
static
final
Event<Synced>
EVENT
Provides a hook to the server, AFTER it has sent packets to the client and synced all Data Attribute’s relevant data, but BEFORE the player exists (i.e. during login).
public
interface
Synced {…}
Nested functional interface for EVENT .

10. API.java

Modifiers and Type Method/Field and Description
public
static
final
String
MODID
The modid for Data Attributes.
public
static
Supplier<EntityAttribute>
getAttribute(Identifier attributeKey)
Returns a Supplier getting the registered attribute assigned to the input key. Uses a supplier because attributes added through json are null until datapacks are loaded/synced to the client, so static initialisation would not work.
public
static
double
add(double current, double adding, double limit)
Adds or subtracts the input values, with diminishing returns tending towards the limit.