Class EnchantmentEvents
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Event
<EnchantmentEvents.AllowEnchanting> An event that allows overriding whether anEnchantment
can be applied to anItemStack
. -
Method Summary
-
Field Details
-
ALLOW_ENCHANTING
An event that allows overriding whether anEnchantment
can be applied to anItemStack
.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, useFabricItem.canBeEnchantedWith(ItemStack, Enchantment, EnchantingContext)
instead. Note that this event triggers beforeFabricItem.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:
-