Class Enchantment

java.lang.Object
org.bukkit.enchantments.Enchantment
All Implemented Interfaces:
Keyed, Translatable, Keyed, Translatable
Direct Known Subclasses:
EnchantmentWrapper

public abstract class Enchantment extends Object implements Keyed, Translatable, Translatable
The various type of enchantments that may be added to armour or weapons
Since:
1.1.0
  • Field Details

    • PROTECTION

      public static final Enchantment PROTECTION
      Provides protection against environmental damage
      Since:
      1.20.6
    • FIRE_PROTECTION

      public static final Enchantment FIRE_PROTECTION
      Provides protection against fire damage
      Since:
      1.20.6
    • FEATHER_FALLING

      public static final Enchantment FEATHER_FALLING
      Provides protection against fall damage
      Since:
      1.20.6
    • BLAST_PROTECTION

      public static final Enchantment BLAST_PROTECTION
      Provides protection against explosive damage
      Since:
      1.20.6
    • PROJECTILE_PROTECTION

      public static final Enchantment PROJECTILE_PROTECTION
      Provides protection against projectile damage
      Since:
      1.20.6
    • RESPIRATION

      public static final Enchantment RESPIRATION
      Decreases the rate of air loss whilst underwater
      Since:
      1.20.6
    • AQUA_AFFINITY

      public static final Enchantment AQUA_AFFINITY
      Increases the speed at which a player may mine underwater
      Since:
      1.20.6
    • THORNS

      public static final Enchantment THORNS
      Damages the attacker
      Since:
      1.4.6
    • DEPTH_STRIDER

      public static final Enchantment DEPTH_STRIDER
      Increases walking speed while in water
      Since:
      1.8
    • FROST_WALKER

      public static final Enchantment FROST_WALKER
      Freezes any still water adjacent to ice / frost which player is walking on
      Since:
      1.9.4
    • BINDING_CURSE

      public static final Enchantment BINDING_CURSE
      Item cannot be removed
      Since:
      1.11
    • SHARPNESS

      public static final Enchantment SHARPNESS
      Increases damage against all targets
      Since:
      1.20.6
    • SMITE

      public static final Enchantment SMITE
      Increases damage against undead targets
      Since:
      1.20.6
    • BANE_OF_ARTHROPODS

      public static final Enchantment BANE_OF_ARTHROPODS
      Increases damage against arthropod targets
      Since:
      1.20.6
    • KNOCKBACK

      public static final Enchantment KNOCKBACK
      All damage to other targets will knock them back when hit
      Since:
      1.1.0
    • FIRE_ASPECT

      public static final Enchantment FIRE_ASPECT
      When attacking a target, has a chance to set them on fire
      Since:
      1.1.0
    • LOOTING

      public static final Enchantment LOOTING
      Provides a chance of gaining extra loot when killing monsters
      Since:
      1.20.6
    • SWEEPING_EDGE

      public static final Enchantment SWEEPING_EDGE
      Increases damage against targets when using a sweep attack
      Since:
      1.11.1
    • EFFICIENCY

      public static final Enchantment EFFICIENCY
      Increases the rate at which you mine/dig
      Since:
      1.20.6
    • SILK_TOUCH

      public static final Enchantment SILK_TOUCH
      Allows blocks to drop themselves instead of fragments (for example, stone instead of cobblestone)
      Since:
      1.1.0
    • UNBREAKING

      public static final Enchantment UNBREAKING
      Decreases the rate at which a tool looses durability
      Since:
      1.20.6
    • FORTUNE

      public static final Enchantment FORTUNE
      Provides a chance of gaining extra loot when destroying blocks
      Since:
      1.20.6
    • POWER

      public static final Enchantment POWER
      Provides extra damage when shooting arrows from bows
      Since:
      1.20.6
    • PUNCH

      public static final Enchantment PUNCH
      Provides a knockback when an entity is hit by an arrow from a bow
      Since:
      1.20.6
    • FLAME

      public static final Enchantment FLAME
      Sets entities on fire when hit by arrows shot from a bow
      Since:
      1.20.6
    • INFINITY

      public static final Enchantment INFINITY
      Provides infinite arrows when shooting a bow
      Since:
      1.20.6
    • LUCK_OF_THE_SEA

      public static final Enchantment LUCK_OF_THE_SEA
      Decreases odds of catching worthless junk
      Since:
      1.20.6
    • LURE

      public static final Enchantment LURE
      Increases rate of fish biting your hook
      Since:
      1.7.2
    • LOYALTY

      public static final Enchantment LOYALTY
      Causes a thrown trident to return to the player who threw it
      Since:
      1.13
    • IMPALING

      public static final Enchantment IMPALING
      Deals more damage to mobs that live in the ocean
      Since:
      1.13
    • RIPTIDE

      public static final Enchantment RIPTIDE
      When it is rainy, launches the player in the direction their trident is thrown
      Since:
      1.13
    • CHANNELING

      public static final Enchantment CHANNELING
      Strikes lightning when a mob is hit with a trident if conditions are stormy
      Since:
      1.13
    • MULTISHOT

      public static final Enchantment MULTISHOT
      Shoot multiple arrows from crossbows
      Since:
      1.14
    • QUICK_CHARGE

      public static final Enchantment QUICK_CHARGE
      Charges crossbows quickly
      Since:
      1.14
    • PIERCING

      public static final Enchantment PIERCING
      Crossbow projectiles pierce entities
      Since:
      1.14
    • DENSITY

      public static final Enchantment DENSITY
      Increases fall damage of maces
      Since:
      1.20.6
    • BREACH

      public static final Enchantment BREACH
      Reduces armor effectiveness against maces
      Since:
      1.20.6
    • WIND_BURST

      public static final Enchantment WIND_BURST
      Emits wind burst upon hitting enemy
      Since:
      1.20.6
    • MENDING

      public static final Enchantment MENDING
      Allows mending the item using experience orbs
      Since:
      1.9.4
    • VANISHING_CURSE

      public static final Enchantment VANISHING_CURSE
      Item disappears instead of dropping
      Since:
      1.11
    • SOUL_SPEED

      public static final Enchantment SOUL_SPEED
      Walk quicker on soul blocks
      Since:
      1.16.1
    • SWIFT_SNEAK

      public static final Enchantment SWIFT_SNEAK
      Walk quicker while sneaking
      Since:
      1.19
    • LUNGE

      public static final Enchantment LUNGE
      Causes a jab attack from a spear to propel the user into the air
      Since:
      1.21.11
  • Constructor Details

    • Enchantment

      public Enchantment()
  • Method Details

    • getName

      @NotNull @Deprecated(since="1.13", forRemoval=true) public abstract @NotNull String getName()
      Deprecated, for removal: This API element is subject to removal in a future version.
      enchantments are badly named, use Keyed.getKey().
      Gets the unique name of this enchantment
      Returns:
      Unique name
    • getMaxLevel

      public abstract int getMaxLevel()
      Gets the maximum level that this Enchantment may become.
      Returns:
      Maximum level of the Enchantment
      Since:
      1.1.0
    • getStartLevel

      public abstract int getStartLevel()
      Gets the level that this Enchantment should start at
      Returns:
      Starting level of the Enchantment
      Since:
      1.1.0
    • getItemTarget

      @NotNull @Deprecated(since="1.20.5", forRemoval=true) @Contract("-> fail") public abstract @NotNull EnchantmentTarget getItemTarget()
      Deprecated, for removal: This API element is subject to removal in a future version.
      enchantment groupings are now managed by tags, not categories
      Gets the type of ItemStack that may fit this Enchantment.
      Returns:
      Target type of the Enchantment
    • isTreasure

      @Deprecated(since="1.21") public abstract boolean isTreasure()
      Deprecated.
      enchantment types are now managed by tags
      Checks if this enchantment is a treasure enchantment.
      Treasure enchantments can only be received via looting, trading, or fishing.
      Returns:
      true if the enchantment is a treasure enchantment
      Since:
      1.10.2
    • isCursed

      public abstract boolean isCursed()
      Checks if this enchantment is a cursed enchantment
      Cursed enchantments are found the same way treasure enchantments are
      Returns:
      true if the enchantment is cursed
      Since:
      1.11
    • conflictsWith

      public abstract boolean conflictsWith(@NotNull @NotNull Enchantment other)
      Check if this enchantment conflicts with another enchantment.
      Parameters:
      other - The enchantment to check against
      Returns:
      True if there is a conflict.
      Since:
      1.3.1
    • canEnchantItem

      public abstract boolean canEnchantItem(@NotNull @NotNull ItemStack item)
      Checks if this Enchantment may be applied to the given ItemStack.

      This does not check if it conflicts with any enchantments already applied to the item.

      Parameters:
      item - Item to test
      Returns:
      True if the enchantment may be applied, otherwise False
      Since:
      1.1.0
    • displayName

      public abstract @NotNull Component displayName(int level)
      Get the name of the enchantment with its applied level.

      If the given level is either less than the getStartLevel() or greater than the getMaxLevel(), the level may not be shown in the numeral format one may otherwise expect.

      Parameters:
      level - the level of the enchantment to show
      Returns:
      the name of the enchantment with level applied
      Since:
      1.16.5
    • isTradeable

      public abstract boolean isTradeable()
      Checks if this enchantment can be found in villager trades.
      Returns:
      true if the enchantment can be found in trades
      Since:
      1.16.5
    • isDiscoverable

      public abstract boolean isDiscoverable()
      Checks if this enchantment can be found in an enchanting table or use to enchant items generated by loot tables.
      Returns:
      true if the enchantment can be found in a table or by loot tables
      Since:
      1.16.5
    • getMinModifiedCost

      public abstract int getMinModifiedCost(int level)
      Gets the minimum modified cost of this enchantment at a specific level.

      Note this is not the number of experience levels needed, and does not directly translate to the levels shown in an enchanting table. This value is used in combination with factors such as tool enchantability to determine a final cost. See https://minecraft.wiki/w/Enchanting/Levels for more information.

      Parameters:
      level - The level of the enchantment
      Returns:
      The modified cost of this enchantment
      Since:
      1.20.2
    • getMaxModifiedCost

      public abstract int getMaxModifiedCost(int level)
      Gets the maximum modified cost of this enchantment at a specific level.

      Note this is not the number of experience levels needed, and does not directly translate to the levels shown in an enchanting table. This value is used in combination with factors such as tool enchantability to determine a final cost. See https://minecraft.wiki/w/Enchanting/Levels for more information.

      Parameters:
      level - The level of the enchantment
      Returns:
      The modified cost of this enchantment
      Since:
      1.20.2
    • getAnvilCost

      public abstract int getAnvilCost()
      Gets cost of applying this enchantment using an anvil.

      Note that this is halved when using an enchantment book, and is multiplied by the level of the enchantment. See https://minecraft.wiki/w/Anvil_mechanics for more information.

      Returns:
      The anvil cost of this enchantment
      Since:
      1.20.6
    • getRarity

      @NotNull @Deprecated(forRemoval=true, since="1.20.5") @Contract("-> fail") public abstract EnchantmentRarity getRarity()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of 1.20.5 enchantments do not have a rarity.
      Gets the rarity of this enchantment.
      Returns:
      the rarity
    • getDamageIncrease

      @Contract("_, _ -> fail") @Deprecated(forRemoval=true, since="1.20.5") public abstract float getDamageIncrease(int level, @NotNull EntityCategory entityCategory)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Enchantments now have a complex effect systems that cannot be reduced to a simple damage increase.
      Gets the damage increase as a result of the level and entity category specified
      Parameters:
      level - the level of enchantment
      entityCategory - the category of entity
      Returns:
      the damage increase
    • getDamageIncrease

      @Contract("_, _ -> fail") @Deprecated(forRemoval=true, since="1.21") public abstract float getDamageIncrease(int level, @NotNull EntityType entityType)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Enchantments now have a complex effect systems that cannot be reduced to a simple damage increase.
      Gets the damage increase as a result of the level and entity type specified
      Parameters:
      level - the level of enchantment
      entityType - the type of entity.
      Returns:
      the damage increase
    • getActiveSlots

      @NotNull @Deprecated(forRemoval=true, since="1.21") public Set<EquipmentSlot> getActiveSlots()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use getActiveSlotGroups() instead as enchantments are now applicable to a group of equipment slots.
      Gets the equipment slots where this enchantment is considered "active".
      Returns:
      the equipment slots
    • getActiveSlotGroups

      @NotNull public abstract Set<EquipmentSlotGroup> getActiveSlotGroups()
      Gets the equipment slots where this enchantment is considered "active".
      Returns:
      the equipment slots
      Since:
      1.21
    • description

      public abstract @NotNull Component description()
      Provides the description of this enchantment entry as displayed to the client, e.g. "Sharpness" for the sharpness enchantment.
      Returns:
      the description component.
      Since:
      1.21.1
    • getSupportedItems

      @Experimental public abstract @NotNull RegistryKeySet<ItemType> getSupportedItems()
      Provides the registry key set referencing the items this enchantment is supported on.
      Returns:
      the registry key set.
      Since:
      1.21.1
    • getPrimaryItems

      @Experimental public abstract @Nullable RegistryKeySet<ItemType> getPrimaryItems()
      Provides the registry key set referencing the item types this enchantment can be applied to when enchanting in an enchantment table.

      If this value is null, getSupportedItems() will be sourced instead in the context of an enchantment table. Additionally, the tag EnchantmentTagKeys.IN_ENCHANTING_TABLE defines which enchantments can even show up in an enchantment table.

      Returns:
      the registry key set.
      Since:
      1.21.1
    • getWeight

      public abstract int getWeight()
      Provides the weight of this enchantment used by the weighted random when selecting enchantments.
      Returns:
      the weight value.
      Since:
      1.21.1
      See Also:
    • getExclusiveWith

      @Experimental public abstract @NotNull RegistryKeySet<Enchantment> getExclusiveWith()
      Provides the registry key set of enchantments that this enchantment is exclusive with.

      Exclusive enchantments prohibit the application of this enchantment to an item if they are already present on said item.

      Returns:
      a registry set of enchantments exclusive to this one.
      Since:
      1.21.1
    • translationKey

      @Deprecated(forRemoval=true) @NotNull public abstract @NotNull String translationKey()
      Deprecated, for removal: This API element is subject to removal in a future version.
      this method assumes that the enchantments description always be a translatable component which is not guaranteed.
      Description copied from interface: net.kyori.adventure.translation.Translatable
      Gets the translation key.
      Specified by:
      translationKey in interface Translatable
      Returns:
      the translation key
    • getByKey

      @Contract("null -> null") @Nullable @Deprecated(since="1.20.3") public static @Nullable Enchantment getByKey(@Nullable @Nullable NamespacedKey key)
      Deprecated.
      only for backwards compatibility, use Registry.get(NamespacedKey) instead
      Gets the Enchantment at the specified key
      Parameters:
      key - key to fetch
      Returns:
      Resulting Enchantment, or null if not found
      Since:
      1.13
    • getByName

      @Deprecated(since="1.13") @Contract("null -> null") @Nullable public static @Nullable Enchantment getByName(@Nullable @Nullable String name)
      Deprecated.
      enchantments are badly named, use getByKey(org.bukkit.NamespacedKey).
      Gets the Enchantment at the specified name
      Parameters:
      name - Name to fetch
      Returns:
      Resulting Enchantment, or null if not found
      Since:
      1.1.0
    • values

      @NotNull @Deprecated(since="1.20.3") public static @NotNull Enchantment[] values()
      Gets an array of all the registered Enchantments
      Returns:
      Array of enchantments
      Since:
      1.1.0