Class LodestoneEnchantmentAttributeHelper

java.lang.Object
team.lodestar.lodestone.modules.toolkit.enchanting.LodestoneEnchantmentAttributeHelper

public class LodestoneEnchantmentAttributeHelper extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    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
    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
    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
    static float
    getAttributeValue(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 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.
    static boolean
    isBaseAttribute(net.minecraft.world.item.component.ItemAttributeModifiers.Entry entry)
    Determines if an attribute modifier entry is a base attribute (not from enchantments)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 check
      filter - An optional filter to only include attribute modifiers from a specific enchantment
      attribute - The attribute to check
      baseValue - 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 check
      baseValue - The base value for the attribute
      attribute - 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 check
      filter - A filter to apply to the modifiers
      baseValue - 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 search
      filter - 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 apply
      baseValue - The base value of the attribute
      Returns:
      The final computed value of the attribute