Class AttributeHelper

java.lang.Object
net.darkhax.bookshelf.api.util.AttributeHelper

public final class AttributeHelper extends Object
This class contains static helper functions for working with entity attributes and calculating attribute values.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    calculateValue(Collection<net.minecraft.world.entity.ai.attributes.AttributeModifier> modifiers, double baseValue)
    Calculates an attribute value using a collection of attribute modifiers.
    static double
    calculateValue(net.minecraft.world.entity.ai.attributes.Attribute attribute, Collection<net.minecraft.world.entity.ai.attributes.AttributeModifier> modifiers)
    Calculates an attribute value using a collection of attribute modifiers.
    static double
    calculateValue(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.ai.attributes.Attribute attribute, net.minecraft.world.entity.EquipmentSlot slot)
    Calculates an attribute value for an ItemStack when used in a given slot.
    static double
    getAttackDamage(net.minecraft.world.item.ItemStack stack)
    Calculates the attack damage attribute value for a given ItemStack.
    static double
    getAttackKnockback(net.minecraft.world.item.ItemStack stack)
    Calculates the attack knockback attribute value for a given ItemStack.
    static double
    getAttackSpeed(net.minecraft.world.item.ItemStack stack)
    Calculates the attack speed attribute value for a given ItemStack.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AttributeHelper

      public AttributeHelper()
  • Method Details

    • getAttackDamage

      public static double getAttackDamage(net.minecraft.world.item.ItemStack stack)
      Calculates the attack damage attribute value for a given ItemStack.
      Parameters:
      stack - The ItemStack to calculate values for.
      Returns:
      The attack damage value for the ItemStack.
    • getAttackSpeed

      public static double getAttackSpeed(net.minecraft.world.item.ItemStack stack)
      Calculates the attack speed attribute value for a given ItemStack.
      Parameters:
      stack - The ItemStack to calculate values for.
      Returns:
      The attack speed value for the ItemStack.
    • getAttackKnockback

      public static double getAttackKnockback(net.minecraft.world.item.ItemStack stack)
      Calculates the attack knockback attribute value for a given ItemStack.
      Parameters:
      stack - The ItemStack to calculate values for.
      Returns:
      The attack knockback value for the ItemStack.
    • calculateValue

      public static double calculateValue(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.ai.attributes.Attribute attribute, net.minecraft.world.entity.EquipmentSlot slot)
      Calculates an attribute value for an ItemStack when used in a given slot.
      Parameters:
      stack - The ItemStack to calculate values for.
      attribute - The attribute to calculate.
      slot - The equipment slot to calculate for.
      Returns:
      The calculated attribute value.
    • calculateValue

      public static double calculateValue(net.minecraft.world.entity.ai.attributes.Attribute attribute, Collection<net.minecraft.world.entity.ai.attributes.AttributeModifier> modifiers)
      Calculates an attribute value using a collection of attribute modifiers.
      Parameters:
      attribute - The attribute to calculate a value for.
      modifiers - A collection of modifiers to process.
      Returns:
      The calculated attribute value.
    • calculateValue

      public static double calculateValue(Collection<net.minecraft.world.entity.ai.attributes.AttributeModifier> modifiers, double baseValue)
      Calculates an attribute value using a collection of attribute modifiers.
      Parameters:
      modifiers - A collection of modifiers to process.
      baseValue - The base value to use for the calculation.
      Returns:
      The calculated attribute value.