Skip to content

Enchantments

Lenni0451 edited this page Jan 4, 2023 · 2 revisions

Enchantments are managed by the EnchantmentRegistry. There are no enchantments registered by default. You have to register them yourself.

Creating an Enchantment

To create an enchantment you need to create an instance of the Enchantment class. The constructor takes the following parameters:

  • name
  • id
  • minLevel
  • maxLevel
  • rarity

Registering an Enchantment

To register an enchantment you need to call the register method.
Since some enchantments are incompatible with each other or can not be applied to every item you also need to specify the incompatibilities.\

Adding an enchantment incompatibility

Registering an enchantment incompatibility is done by calling the addIncompatibility(enchantment, enchantment2) method.

Adding an enchantment item incompatibility

Adding an item incompatibility is done by calling the addItemCompatibility(item, testFunction) method.
The testFunction is a function that takes an item as a parameter and returns a boolean (true -> incompatible).

Clone this wiki locally