Package net.darkhax.bookshelf.api.util
Class AttributeHelper
java.lang.Object
net.darkhax.bookshelf.api.util.AttributeHelper
This class contains static helper functions for working with entity attributes and calculating attribute values.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublecalculateValue(Collection<net.minecraft.world.entity.ai.attributes.AttributeModifier> modifiers, double baseValue) Calculates an attribute value using a collection of attribute modifiers.static doublecalculateValue(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 doublecalculateValue(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 doublegetAttackDamage(net.minecraft.world.item.ItemStack stack) Calculates the attack damage attribute value for a given ItemStack.static doublegetAttackKnockback(net.minecraft.world.item.ItemStack stack) Calculates the attack knockback attribute value for a given ItemStack.static doublegetAttackSpeed(net.minecraft.world.item.ItemStack stack) Calculates the attack speed attribute value for a given ItemStack.
-
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.
-