enchants

abstract fun enchants(items: RegistryEntrySet.Paper<ItemType>)

Sets the item types to which this enchantment can be applied to, for example, in an anvil.

To have the enchanment appear in the enchanting table for some item types and only be applicable via the anvil for others, define enchants for all supported item types, then enchantsPrimary for all item types for which the enchantment is supposed to show up in the enchanting table and set tableDiscoverable to true. If you need no such distinction, only define the enchants item type set and they will be considered "primary" as well.

For your own custom items, you can also configure the supported enchantments via the Enchantable item behavior.