Class EnchantmentEvents

java.lang.Object
net.fabricmc.fabric.api.item.v1.EnchantmentEvents

public final class EnchantmentEvents extends Object
Events relating to enchantments, allowing for finer control of what enchantments can apply to different items.
  • Field Details

    • ALLOW_ENCHANTING

      public static final Event<EnchantmentEvents.AllowEnchanting> ALLOW_ENCHANTING
      An event that allows overriding whether an Enchantment can be applied to an ItemStack.

      This should only be used to modify the behavior of external items with regards to external enchantments, where 'external' means either vanilla or from another mod. For instance, a mod might allow enchanting a pickaxe with Sharpness (and only Sharpness) under certain specific conditions.

      To modify the behavior of your own modded enchantments, use Enchantment.isAcceptableItem(ItemStack) instead. To modify the behavior of your own modded items, use

      invalid reference
      FabricItem#canBeEnchantedWith(ItemStack, Enchantment, EnchantingContext)
      instead. Note that this event triggers before
      invalid reference
      FabricItem#canBeEnchantedWith(ItemStack, Enchantment, EnchantingContext)
      , and that method will only be called if no listeners override it.

      Note that allowing an enchantment using this event does not guarantee the item will receive that enchantment, only that it isn't forbidden from doing so.

      See Also: