Class EnchantmentEvents
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Event
<EnchantmentEvents.AllowEnchanting> An event that allows overriding whether anEnchantment
can be applied to anItemStack
.static final Event
<EnchantmentEvents.Modify> An event that allows anEnchantment
to be modified without needing to fully override an enchantment. -
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, specify a custom tag for
Enchantment.Definition.supportedItems()
instead. To modify the behavior of your own modded items, add to the applicable tags instead, when that suffices. Note that this event triggers beforeFabricItem.canBeEnchantedWith(ItemStack, RegistryEntry, 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:
-
MODIFY
An event that allows anEnchantment
to be modified without needing to fully override an enchantment.This should only be used to modify the behavior of external enchantments, where 'external' means either vanilla or from another mod. For instance, a mod might add a bleed effect to Sharpness (and only Sharpness). For your own enchantments, you should simply define them in your mod's data pack. See the Enchantment Definition page on the Minecraft Wiki for more information.
Note: If you wish to modify the exclusive set of the enchantment, consider extending the relevant tag through your mod's data pack instead.
-