Important: This section is now outdated and unsupported. Click here for the latest release.
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 | 
|---|---|
publicstaticfinalAttributeBehaviour | 
      FLAT  Flat/normal addition behaviour.  | 
    
publicstaticfinalAttributeBehaviour | 
      DIMINISHING  Diminishing addition behaviour.  | 
    
publicbyte | 
      id()  Returns the byte id of the behaviour enum.  | 
    
publicdouble | 
      result(double current, double adding, double limit)  Returns the inputs through the correct function for the specific behaviour type.  | 
    
publicstaticAttributeBehaviour | 
      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 | 
|---|---|
publicstaticfinalEvent<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).  | 
    
publicinterface | 
      Synced {…}  Nested functional interface for EVENT . | 
    
7. event.EntityAttributeEvents.java
| Modifiers and Type | Method/Field and Description | 
|---|---|
publicstaticfinalEvent<AddedPre> | 
      MODIFIER_ADDED_PRE  Fired before an EntityAttributeModifier is added to an EntityAttributeInstance. | 
    
publicstaticfinalEvent<AddedPost> | 
      MODIFIER_ADDED_POST  Fired after an EntityAttributeModifier is added to an EntityAttributeInstance. | 
    
publicstaticfinalEvent<RemovedPre> | 
      MODIFIER_REMOVED_PRE  Fired before an EntityAttributeModifier is removed from an EntityAttributeInstance. | 
    
publicstaticfinalEvent<RemovedPost> | 
      MODIFIER_REMOVED_POST  Fired after an EntityAttributeModifier is removed from an EntityAttributeInstance. | 
    
publicinterface | 
      AddedPre {…}  Nested functional interface for MODIFIER_ADDED_PRE . | 
    
publicinterface | 
      AddedPost {…}  Nested functional interface for MODIFIER_ADDED_POST . | 
    
publicinterface | 
      RemovedPre {…}  Nested functional interface for MODIFIER_REMOVED_PRE . | 
    
publicinterface | 
      RemovedPost {…}  Nested functional interface for MODIFIER_REMOVED_POST . | 
    
8. event.MathClamp.java
| Modifiers and Type | Method/Field and Description | 
|---|---|
publicstaticfinalEvent<Clamp> | 
      EVENT  Fired on EntityAttribute#clamp and on ClampedEntityAttribute#clamp but before MathHelper#clamp is called. | 
    
publicinterface | 
      Clamp {…}  Nested functional interface for EVENT . | 
    
9. event.ServerSyncedEvent.java
| Modifiers and Type | Method/Field and Description | 
|---|---|
publicstaticfinalEvent<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).  | 
    
publicinterface | 
      Synced {…}  Nested functional interface for EVENT . | 
    
10. API.java
| Modifiers and Type | Method/Field and Description | 
|---|---|
publicstaticfinalString | 
      MODID  The modid for Data Attributes.  | 
    
publicstaticSupplier<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. | 
    
publicstaticdouble | 
      add(double current, double adding, double limit)  Adds or subtracts the input values, with diminishing returns tending towards the limit.  |