Interface EnchantmentDefinition

All Superinterfaces:
Keyed

@NonExtendable public interface EnchantmentDefinition extends Keyed
A complete enchantment definition, ready to be sent to clients.

Definitions are created through Enchantments.define(TypedKey) or read from data pack JSON. Vanilla enchantments are exposed as definitions as well.

The minecraft:enchantment registry is synchronised with clients during the configuration phase, so vanilla clients display custom enchantments without any mod. Their behaviour runs on the server, through the effect components of their data and their EnchantmentBehaviours.

Since:
0.1.0
  • Field Details

    • MAX_LEVEL

      static final int MAX_LEVEL
      The highest level of an enchantment.
      Since:
      0.1.0
      See Also:
    • MAX_WEIGHT

      static final int MAX_WEIGHT
      The highest weight of an enchantment.
      Since:
      0.1.0
      See Also:
  • Method Details

    • typedKey

      @Contract(pure=true) default TypedKey<EnchantmentDefinition> typedKey()
      Returns this enchantment's key, typed against the minecraft:enchantment registry.
      Returns:
      this enchantment's key, typed against the minecraft:enchantment registry
      Since:
      0.1.0
    • description

      Component description()
      Returns the name of the enchantment, without its level.
      Returns:
      the name of the enchantment, without its level
      Since:
      0.1.0
    • supportedItems

      KeySet<Item> supportedItems()
      Returns the items the enchantment can be applied to.
      Returns:
      the items the enchantment can be applied to
      Since:
      0.1.0
    • primaryItems

      Optional<KeySet<Item>> primaryItems()
      Returns the items the enchanting table offers the enchantment for, or empty to use supportedItems().
      Returns:
      the items the enchanting table offers the enchantment for, or empty to use supportedItems()
      Since:
      0.1.0
    • exclusiveSet

      KeySet<EnchantmentDefinition> exclusiveSet()
      Returns the enchantments incompatible with this one, possibly empty.
      Returns:
      the enchantments incompatible with this one, possibly empty
      Since:
      0.1.0
    • maxLevel

      int maxLevel()
      Returns the maximum level, between 1 and 255.
      Returns:
      the maximum level, between 1 and 255
      Since:
      0.1.0
    • weight

      int weight()
      Returns the weight of the enchantment in random selections, between 1 and 1024.
      Returns:
      the weight of the enchantment in random selections, between 1 and 1024
      Since:
      0.1.0
    • anvilCost

      int anvilCost()
      Returns the base anvil cost per level.
      Returns:
      the base anvil cost per level
      Since:
      0.1.0
    • minCost

      Returns the minimum enchanting cost of each level.
      Returns:
      the minimum enchanting cost of each level
      Since:
      0.1.0
    • maxCost

      Returns the maximum enchanting cost of each level.
      Returns:
      the maximum enchanting cost of each level
      Since:
      0.1.0
    • slots

      Returns the equipment slots in which the enchantment is active.
      Returns:
      the equipment slots in which the enchantment is active
      Since:
      0.1.0
    • matchesSlot

      default boolean matchesSlot(EquipmentSlot slot)
      Returns true if the enchantment is active in slot.
      Parameters:
      slot - the equipment slot
      Returns:
      true if the enchantment is active in slot
      Since:
      0.1.0
    • effectComponents

      Set<Key> effectComponents()
      Returns the effect components declared by the enchantment, such as minecraft:damage.
      Returns:
      the effect components declared by the enchantment, such as minecraft:damage
      Since:
      0.1.0
      See Also:
    • hasEffect

      default boolean hasEffect(Key component)
      Returns true if the enchantment declares the effect component component.
      Parameters:
      component - the effect component, see EnchantmentEffects
      Returns:
      true if the enchantment declares the effect component component
      Since:
      0.1.0
    • effectsJson

      Optional<String> effectsJson()
      Returns the effects object of the enchantment as JSON, or empty if it declares no effect component.
      Returns:
      the effects object of the enchantment as JSON, or empty if it declares no effect component
      Since:
      0.1.0
    • behaviour

      Returns the behaviour of this definition, if any.

      Behaviours attached to the enchantment are not included.

      Returns:
      the behaviour of this definition, if any
      Since:
      0.1.0
    • toJson

      String toJson()
      Returns this definition in its data pack JSON representation.
      Returns:
      this definition in its data pack JSON representation
      Since:
      0.1.0
    • toBuilder

      Returns a new builder pre-filled with the values of this definition.
      Returns:
      a new builder pre-filled with the values of this definition
      Since:
      0.1.0