Class Enchantment

java.lang.Object
org.bukkit.enchantments.Enchantment
All Implemented Interfaces:
net.kyori.adventure.key.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
  • Field Details

    • PROTECTION

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

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

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

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

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

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

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

      public static final Enchantment THORNS
      Damages the attacker
    • DEPTH_STRIDER

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

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

      public static final Enchantment BINDING_CURSE
      Item cannot be removed
    • SHARPNESS

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public static final Enchantment QUICK_CHARGE
      Charges crossbows quickly
    • PIERCING

      public static final Enchantment PIERCING
      Crossbow projectiles pierce entities
    • DENSITY

      Increases fall damage of maces
    • BREACH

      Reduces armor effectiveness against maces
    • WIND_BURST

      Emits wind burst upon hitting enemy
    • MENDING

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

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

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

      public static final Enchantment SWIFT_SNEAK
      Walk quicker while sneaking
  • Constructor Details

    • Enchantment

      public Enchantment()
  • Method Details

    • getName

      @NotNull @Deprecated public abstract @NotNull String getName()
      Deprecated.
      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
    • getStartLevel

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

      @NotNull @Deprecated(forRemoval=true, since="1.20.5") @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

      public abstract boolean isTreasure()
      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
    • 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
    • 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.
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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

      @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.
      Use getDamageIncrease(int, org.bukkit.entity.EntityType) instead. Enchantment damage increase is no longer handled via EntityCategorys, but is instead controlled by tags, e.g. Tag.ENTITY_TYPES_SENSITIVE_TO_BANE_OF_ARTHROPODS. As such, a category cannot properly represent all entities defined by the tags.
      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

      public abstract float getDamageIncrease(int level, @NotNull EntityType entityType)
      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 public abstract Set<EquipmentSlot> getActiveSlots()
      Gets the equipment slots where this enchantment is considered "active".
      Returns:
      the equipment slots
    • getByKey

      @Contract("null -> null") @Nullable @Deprecated 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
    • getByName

      @Deprecated @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
    • values

      @NotNull @Deprecated public static @NotNull Enchantment[] values()
      Gets an array of all the registered Enchantments
      Returns:
      Array of enchantments