Class BaseEnchantment

java.lang.Object
net.minecraft.world.item.enchantment.Enchantment
net.darkhax.bookshelf.api.enchantment.BaseEnchantment
Direct Known Subclasses:
CurseEnchantment

public class BaseEnchantment extends net.minecraft.world.item.enchantment.Enchantment
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.world.item.enchantment.Enchantment

    net.minecraft.world.item.enchantment.Enchantment.Rarity
  • Field Summary

    Fields inherited from class net.minecraft.world.item.enchantment.Enchantment

    category, descriptionId
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseEnchantment(net.minecraft.world.item.enchantment.Enchantment.Rarity rarity, net.minecraft.world.item.enchantment.EnchantmentCategory category, net.minecraft.world.entity.EquipmentSlot... slots)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    applyModifiers(int level, BiConsumer<net.minecraft.world.entity.ai.attributes.Attribute,net.minecraft.world.entity.ai.attributes.AttributeModifier> adder)
    Allows the enchantment to apply attribute modifiers to an enchanted item.
    void
    applyModifiers(net.minecraft.world.item.ItemStack stack, int level, net.minecraft.world.entity.EquipmentSlot slot, BiConsumer<net.minecraft.world.entity.ai.attributes.Attribute,net.minecraft.world.entity.ai.attributes.AttributeModifier> adder)
    Allows the enchantment to apply attribute modifiers to an enchanted item.
    boolean
    isValidSlot(net.minecraft.world.entity.EquipmentSlot slot)
     

    Methods inherited from class net.minecraft.world.item.enchantment.Enchantment

    byId, canEnchant, checkCompatibility, doPostAttack, doPostHurt, getDamageBonus, getDamageProtection, getDescriptionId, getFullname, getMaxCost, getMaxLevel, getMinCost, getMinLevel, getOrCreateDescriptionId, getRarity, getSlotItems, isCompatibleWith, isCurse, isDiscoverable, isTradeable, isTreasureOnly

    Methods inherited from class java.lang.Object

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

    • BaseEnchantment

      public BaseEnchantment(net.minecraft.world.item.enchantment.Enchantment.Rarity rarity, net.minecraft.world.item.enchantment.EnchantmentCategory category, net.minecraft.world.entity.EquipmentSlot... slots)
  • Method Details

    • applyModifiers

      public void applyModifiers(net.minecraft.world.item.ItemStack stack, int level, net.minecraft.world.entity.EquipmentSlot slot, BiConsumer<net.minecraft.world.entity.ai.attributes.Attribute,net.minecraft.world.entity.ai.attributes.AttributeModifier> adder)
      Allows the enchantment to apply attribute modifiers to an enchanted item. This may be called many times with different item/slot combinations, especially in cases like tooltips. In most cases you should override applyModifiers(int, BiConsumer) instead, as it has boilerplate checks for the correct slot type built in.
      Parameters:
      stack - The enchanted ItemStack.
      level - The level of the enchantment. This will always be at least 1.
      slot - The slot being tested. This is not necessarily the slot the item is currently in, for example tooltips will test all slots.
      adder - A function to add your new modifiers.
    • applyModifiers

      public void applyModifiers(int level, BiConsumer<net.minecraft.world.entity.ai.attributes.Attribute,net.minecraft.world.entity.ai.attributes.AttributeModifier> adder)
      Allows the enchantment to apply attribute modifiers to an enchanted item. This will only be applied if the item is in a valid slot for this type of enchantment.
      Parameters:
      level - The level of the enchantment. This will always be at least 1.
      adder - A function to add your new modifiers.
    • isValidSlot

      public boolean isValidSlot(net.minecraft.world.entity.EquipmentSlot slot)