Class LodestoneEnchantmentAttributeHelper
java.lang.Object
team.lodestar.lodestone.systems.enchanting.LodestoneEnchantmentAttributeHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.item.component.ItemAttributeModifiersasAttributeModifiers(com.google.common.collect.Multimap<net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>, net.minecraft.world.entity.ai.attributes.AttributeModifier> map) Converts a Multimap of AttributeModifiers into an ItemAttributeModifiers instancestatic floatcompute(net.minecraft.world.entity.ai.attributes.AttributeModifier modifier, double baseValue) Computes the final value of an attribute given a single modifier and a base valuestatic floatcompute(net.minecraft.world.item.component.ItemAttributeModifiers modifiers, Predicate<net.minecraft.world.item.component.ItemAttributeModifiers.Entry> filter, double baseValue) Computes the final value of an attribute given a set of modifiers and a base valuestatic com.google.common.collect.Multimap<net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>, net.minecraft.world.entity.ai.attributes.AttributeModifier> findMatching(net.minecraft.world.item.component.ItemAttributeModifiers modifiers, Predicate<net.minecraft.world.item.component.ItemAttributeModifiers.Entry> filter) Finds all matching attribute modifiers from an ItemAttributeModifiers instance based on a filterstatic floatgetAttributeValue(net.minecraft.world.item.ItemStack stack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> filter, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute, float baseValue) Gets the value of an attribute on an item based on modifications from enchantments.static floatgetBaseValue(net.minecraft.world.item.component.ItemAttributeModifiers modifiers, float baseValue, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute) Returns the raw value of an attribute on an item as it is by vanilla rules.static booleanisBaseAttribute(net.minecraft.world.item.component.ItemAttributeModifiers.Entry entry) Determines if an attribute modifier entry is a base attribute (not from enchantments)
-
Constructor Details
-
LodestoneEnchantmentAttributeHelper
public LodestoneEnchantmentAttributeHelper()
-
-
Method Details
-
getAttributeValue
public static float getAttributeValue(net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> filter, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute, float baseValue) Gets the value of an attribute on an item based on modifications from enchantments.- Parameters:
stack- The item stack to checkfilter- An optional filter to only include attribute modifiers from a specific enchantmentattribute- The attribute to checkbaseValue- The base value of the attribute- Returns:
- The value of the attribute including enchantment modifications
-
getBaseValue
public static float getBaseValue(net.minecraft.world.item.component.ItemAttributeModifiers modifiers, float baseValue, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute) Returns the raw value of an attribute on an item as it is by vanilla rules. Any influence from enchantments is ignored.- Parameters:
modifiers- The item's modifiers to checkbaseValue- The base value for the attributeattribute- The attribute to check for- Returns:
- The value representing the attribute without any enchantment influence.
-
isBaseAttribute
public static boolean isBaseAttribute(net.minecraft.world.item.component.ItemAttributeModifiers.Entry entry) Determines if an attribute modifier entry is a base attribute (not from enchantments)- Parameters:
entry- The entry to check- Returns:
- True if the entry is a base attribute, false if it is from an enchantment
-
asAttributeModifiers
public static net.minecraft.world.item.component.ItemAttributeModifiers asAttributeModifiers(com.google.common.collect.Multimap<net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>, net.minecraft.world.entity.ai.attributes.AttributeModifier> map) Converts a Multimap of AttributeModifiers into an ItemAttributeModifiers instance- Parameters:
map- The map to convert- Returns:
- The converted ItemAttributeModifiers
-
compute
public static float compute(net.minecraft.world.item.component.ItemAttributeModifiers modifiers, Predicate<net.minecraft.world.item.component.ItemAttributeModifiers.Entry> filter, double baseValue) Computes the final value of an attribute given a set of modifiers and a base value- Parameters:
modifiers- The modifiers to checkfilter- A filter to apply to the modifiersbaseValue- The base value of the attribute- Returns:
- The final computed value of the attribute
-
findMatching
public static com.google.common.collect.Multimap<net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>,net.minecraft.world.entity.ai.attributes.AttributeModifier> findMatching(net.minecraft.world.item.component.ItemAttributeModifiers modifiers, Predicate<net.minecraft.world.item.component.ItemAttributeModifiers.Entry> filter) Finds all matching attribute modifiers from an ItemAttributeModifiers instance based on a filter- Parameters:
modifiers- The modifiers to searchfilter- The filter to apply to the modifiers- Returns:
- A Multimap of matching attribute modifiers
-
compute
public static float compute(net.minecraft.world.entity.ai.attributes.AttributeModifier modifier, double baseValue) Computes the final value of an attribute given a single modifier and a base value- Parameters:
modifier- The modifier to applybaseValue- The base value of the attribute- Returns:
- The final computed value of the attribute
-