Skip to content

API 1.17.1

CleverNucleus edited this page Jan 14, 2022 · 1 revision

Data Attributes includes an API package located at com.github.clevernucleus.dataattributes.api. The package includes:

  • attribute.AdditionFunction.java
  • attribute.AttributeBehaviour.java
  • attribute.IAttribute.java
  • attribute.IAttributeFunction.java
  • event.EntityAttributeEvents.java
  • API.java

API.java

public final class

  • public static final String MODID
    • Global access to Data Attribute's modid.
  • public static Supplier<EntityAttribute> #getAttribute(Identifier attribute)
    • A method that provides a way to statically initialise a reference to an entity attribute that may or may not exist in a given scenario at a given time, due to the nature of datapacks.
  • public static double #add(double current, double adding, double limit)
    • A maths method that calculates diminishing additions, see Behaviour.

attribute.AdditionFunction.java

public interface

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

attribute.AttributeBehaviour.java

public enum

  • FLAT
    • Reference to the FLAT behaviour for attribute functions.
  • DIMINISHING
    • Reference to the DIMINISHING behaviour for attribute functions.
  • public static AttributeBehaviour #fromId(byte id)
    • Takes a byte id and returns the corresponding behaviour type.
  • public byte #id()
    • Returns the byte id of the behaviour.
  • public double #result(double current, double adding, double limit)
    • Runs the inputs through the correct function for the specific behaviour type.

attribute.IAttribute.java

public interface

  • double #getDefaultValue()
    • Returns the entity attribute's default value.
  • double #getMinValue()
    • Returns the entity attribute's minimum value.
  • double #getMaxValue()
    • Returns the entity attribute's maximum value.
  • double #clamp(double value)
    • Returns the input value if it is between the minimum and maximum values, else returns the minimum or maximum values.
  • String #getTranslationKey()
    • Returns the entity attribute's translation key.
  • Collection<String> #properties()
    • Returns an immutable set of all the properties' keys assigned to this attribute.
  • boolean #hasProperty(String property)
    • Returns true if this entity attribute has the input property.
  • float #getProperty(String property)
    • Returns the input property's value if it exists, if not returns 0.
  • Collection<IAttributeFunction> #functions()
    • Returns an immutable set of all the attribute functions attached to this entity attribute.

attribute.IAttributeFunction.java

public interface

  • Identifier #attribute()
    • Returns the registry key associated with this function's attribute.
  • AttributeBehaviour #behaviour()
    • Returns the behaviour type associated with this function..
  • double #multiplier()
    • Returns the multiplier associated with this function.

event.EntityAttributeEvents.java

public final class

  • public static final Event<...> MODIFIER_ADDED_PRE
    • Fired before an EntityAttributeModifier is applied to an EntityAttributeInstance. Allows for the value of the modifier to be changed before it is applied.
  • public static final Event<...> MODIFIER_ADDED_POST
    • Fired after an EntityAttributeModifier has been applied to an EntityAttributeInstance.
  • public static final Event<...> MODIFIER_REMOVED_PRE
    • Fired before an EntityAttributeModifier is removed from an EntityAttributeInstance.
  • public static final Event<...> MODIFIER_REMOVED_POST
    • Fired after an EntityAttributeModifier has been removed from an EntityAttributeInstance.