Class Enchantment
- All Implemented Interfaces:
Keyed,Translatable,Keyed,Translatable
- Direct Known Subclasses:
EnchantmentWrapper
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EnchantmentIncreases the speed at which a player may mine underwaterstatic final EnchantmentIncreases damage against arthropod targetsstatic final EnchantmentItem cannot be removedstatic final EnchantmentProvides protection against explosive damagestatic final EnchantmentReduces armor effectiveness against macesstatic final EnchantmentStrikes lightning when a mob is hit with a trident if conditions are stormystatic final EnchantmentIncreases fall damage of macesstatic final EnchantmentIncreases walking speed while in waterstatic final EnchantmentIncreases the rate at which you mine/digstatic final EnchantmentProvides protection against fall damagestatic final EnchantmentWhen attacking a target, has a chance to set them on firestatic final EnchantmentProvides protection against fire damagestatic final EnchantmentSets entities on fire when hit by arrows shot from a bowstatic final EnchantmentProvides a chance of gaining extra loot when destroying blocksstatic final EnchantmentFreezes any still water adjacent to ice / frost which player is walking onstatic final EnchantmentDeals more damage to mobs that live in the oceanstatic final EnchantmentProvides infinite arrows when shooting a bowstatic final EnchantmentAll damage to other targets will knock them back when hitstatic final EnchantmentProvides a chance of gaining extra loot when killing monstersstatic final EnchantmentCauses a thrown trident to return to the player who threw itstatic final EnchantmentDecreases odds of catching worthless junkstatic final EnchantmentIncreases rate of fish biting your hookstatic final EnchantmentAllows mending the item using experience orbsstatic final EnchantmentShoot multiple arrows from crossbowsstatic final EnchantmentCrossbow projectiles pierce entitiesstatic final EnchantmentProvides extra damage when shooting arrows from bowsstatic final EnchantmentProvides protection against projectile damagestatic final EnchantmentProvides protection against environmental damagestatic final EnchantmentProvides a knockback when an entity is hit by an arrow from a bowstatic final EnchantmentCharges crossbows quicklystatic final EnchantmentDecreases the rate of air loss whilst underwaterstatic final EnchantmentWhen it is rainy, launches the player in the direction their trident is thrownstatic final EnchantmentIncreases damage against all targetsstatic final EnchantmentAllows blocks to drop themselves instead of fragments (for example, stone instead of cobblestone)static final EnchantmentIncreases damage against undead targetsstatic final EnchantmentWalk quicker on soul blocksstatic final EnchantmentIncreases damage against targets when using a sweep attackstatic final EnchantmentWalk quicker while sneakingstatic final EnchantmentDamages the attackerstatic final EnchantmentDecreases the rate at which a tool looses durabilitystatic final EnchantmentItem disappears instead of droppingstatic final EnchantmentEmits wind burst upon hitting enemy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancanEnchantItem(@NotNull ItemStack item) Checks if this Enchantment may be applied to the givenItemStack.abstract booleanconflictsWith(@NotNull Enchantment other) Check if this enchantment conflicts with another enchantment.Provides the description of this enchantment entry as displayed to the client, e.g.displayName(int level) Get the name of the enchantment with its applied level.abstract Set<EquipmentSlotGroup> Gets the equipment slots where this enchantment is considered "active".Deprecated, for removal: This API element is subject to removal in a future version.abstract intGets cost of applying this enchantment using an anvil.static @Nullable EnchantmentDeprecated.only for backwards compatibility, useRegistry.get(NamespacedKey)insteadstatic @Nullable EnchantmentDeprecated.enchantments are badly named, usegetByKey(org.bukkit.NamespacedKey).abstract floatgetDamageIncrease(int level, 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.abstract floatgetDamageIncrease(int level, 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.abstract @NotNull RegistryKeySet<Enchantment> Provides the registry key set of enchantments that this enchantment is exclusive with.abstract @NotNull EnchantmentTargetDeprecated, for removal: This API element is subject to removal in a future version.enchantment groupings are now managed by tags, not categoriesabstract intGets the maximum level that this Enchantment may become.abstract intgetMaxModifiedCost(int level) Gets the maximum modified cost of this enchantment at a specific level.abstract intgetMinModifiedCost(int level) Gets the minimum modified cost of this enchantment at a specific level.getName()Deprecated.enchantments are badly named, useKeyed.getKey().abstract @Nullable RegistryKeySet<ItemType> Provides the registry key set referencing the item types this enchantment can be applied to when enchanting in an enchantment table.abstract EnchantmentRarityDeprecated, for removal: This API element is subject to removal in a future version.As of 1.20.5 enchantments do not have a rarity.abstract intGets the level that this Enchantment should start atabstract @NotNull RegistryKeySet<ItemType> Provides the registry key set referencing the items this enchantment is supported on.abstract intProvides the weight of this enchantment used by the weighted random when selecting enchantments.abstract booleanisCursed()Checks if this enchantment is a cursed enchantment
Cursed enchantments are found the same way treasure enchantments areabstract booleanChecks if this enchantment can be found in an enchanting table or use to enchant items generated by loot tables.abstract booleanChecks if this enchantment can be found in villager trades.abstract booleanDeprecated.enchantment types are now managed by tagsDeprecated, 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.static @NotNull Enchantment[]values()Deprecated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bukkit.Translatable
getTranslationKey
-
Field Details
-
PROTECTION
Provides protection against environmental damage -
FIRE_PROTECTION
Provides protection against fire damage -
FEATHER_FALLING
Provides protection against fall damage -
BLAST_PROTECTION
Provides protection against explosive damage -
PROJECTILE_PROTECTION
Provides protection against projectile damage -
RESPIRATION
Decreases the rate of air loss whilst underwater -
AQUA_AFFINITY
Increases the speed at which a player may mine underwater -
THORNS
Damages the attacker -
DEPTH_STRIDER
Increases walking speed while in water -
FROST_WALKER
Freezes any still water adjacent to ice / frost which player is walking on -
BINDING_CURSE
Item cannot be removed -
SHARPNESS
Increases damage against all targets -
SMITE
Increases damage against undead targets -
BANE_OF_ARTHROPODS
Increases damage against arthropod targets -
KNOCKBACK
All damage to other targets will knock them back when hit -
FIRE_ASPECT
When attacking a target, has a chance to set them on fire -
LOOTING
Provides a chance of gaining extra loot when killing monsters -
SWEEPING_EDGE
Increases damage against targets when using a sweep attack -
EFFICIENCY
Increases the rate at which you mine/dig -
SILK_TOUCH
Allows blocks to drop themselves instead of fragments (for example, stone instead of cobblestone) -
UNBREAKING
Decreases the rate at which a tool looses durability -
FORTUNE
Provides a chance of gaining extra loot when destroying blocks -
POWER
Provides extra damage when shooting arrows from bows -
PUNCH
Provides a knockback when an entity is hit by an arrow from a bow -
FLAME
Sets entities on fire when hit by arrows shot from a bow -
INFINITY
Provides infinite arrows when shooting a bow -
LUCK_OF_THE_SEA
Decreases odds of catching worthless junk -
LURE
Increases rate of fish biting your hook -
LOYALTY
Causes a thrown trident to return to the player who threw it -
IMPALING
Deals more damage to mobs that live in the ocean -
RIPTIDE
When it is rainy, launches the player in the direction their trident is thrown -
CHANNELING
Strikes lightning when a mob is hit with a trident if conditions are stormy -
MULTISHOT
Shoot multiple arrows from crossbows -
QUICK_CHARGE
Charges crossbows quickly -
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
Allows mending the item using experience orbs -
VANISHING_CURSE
Item disappears instead of dropping -
SOUL_SPEED
Walk quicker on soul blocks -
SWIFT_SNEAK
Walk quicker while sneaking
-
-
Constructor Details
-
Enchantment
public Enchantment()
-
-
Method Details
-
getName
Deprecated.enchantments are badly named, useKeyed.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(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 categoriesGets the type ofItemStackthat may fit this Enchantment.- Returns:
- Target type of the Enchantment
-
isTreasure
Deprecated.enchantment types are now managed by tagsChecks 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
Check if this enchantment conflicts with another enchantment.- Parameters:
other- The enchantment to check against- Returns:
- True if there is a conflict.
-
canEnchantItem
Checks if this Enchantment may be applied to the givenItemStack.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
Get the name of the enchantment with its applied level.If the given
levelis either less than thegetStartLevel()or greater than thegetMaxLevel(), 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
levelapplied
-
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
@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 enchantmententityCategory- 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 enchantmententityType- the type of entity.- Returns:
- the damage increase
-
getActiveSlots
Deprecated, for removal: This API element is subject to removal in a future version.UsegetActiveSlotGroups()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
Gets the equipment slots where this enchantment is considered "active".- Returns:
- the equipment slots
-
description
Provides the description of this enchantment entry as displayed to the client, e.g. "Sharpness" for the sharpness enchantment.- Returns:
- the description component.
-
getSupportedItems
Provides the registry key set referencing the items this enchantment is supported on.- Returns:
- the registry key set.
-
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 tagEnchantmentTagKeys.IN_ENCHANTING_TABLEdefines which enchantments can even show up in an enchantment table.- Returns:
- the registry key set.
-
getWeight
public abstract int getWeight()Provides the weight of this enchantment used by the weighted random when selecting enchantments.- Returns:
- the weight value.
- See Also:
-
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.
-
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.TranslatableGets the translation key.- Specified by:
translationKeyin interfaceTranslatable- 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, useRegistry.get(NamespacedKey)insteadGets the Enchantment at the specified key- Parameters:
key- key to fetch- Returns:
- Resulting Enchantment, or null if not found
-
getByName
@Deprecated(since="1.13") @Contract("null -> null") @Nullable public static @Nullable Enchantment getByName(@Nullable @Nullable String name) Deprecated.enchantments are badly named, usegetByKey(org.bukkit.NamespacedKey).Gets the Enchantment at the specified name- Parameters:
name- Name to fetch- Returns:
- Resulting Enchantment, or null if not found
-
values
Deprecated.Gets an array of all the registeredEnchantments- Returns:
- Array of enchantments
-
getActiveSlotGroups()instead as enchantments are now applicable to a group of equipment slots.