Commands/enchant

From Minecraft Wiki
Jump to: navigation, search

Adds an enchantment to a player's selected item, subject to the same restrictions as an anvil.

Syntax[edit]

  • Java Edition
enchant <targets> <enchantment> [<level>]
  • Bedrock Edition
enchant <player: target> <enchantmentId: int> [level: int]
enchant <player: target> <enchantmentName: Enchant> [level: int]

Arguments[edit]

JE<targets>: entity
BE: player: target: CommandSelector<Actor>

Must be a player name, a target selector or a UUID[Java Edition only]
Specifies the target(s).

JE: <enchantment>: item_enchantment
BE: enchantmentId: int: int or <enchantmentName: Enchant>: Enchant::Type

Specifies the enchantment to be added to the item held by the target.

JE<level>: integer
BE: level: int: int

Must be a 32-bit integer number. In Java Edition, it must be between 0 and 2147483647 (inclusive). In Bedrock Edition, it must be between 1 and 2147483647 (inclusive).
Specifies the enchantment level. Should be not greater than the maximum level for the specified enchantment[note 1]. If not specified, defaults to 1.

Result[edit]

CommandTriggerJava EditionBedrock Edition
anythe arguments are not specified correctly Unparseable Failed
if <targets> or player: target fails to resolve to one or more entities (named player must be online) Failed
if <level> or level: int is greater than the maximum level for the specified enchantment
if there's no item in any entity's hand
if the enchantment is not valid for items held by any targets
if the enchantment conflicts with current enchantments (for example, "Piercing" cannot be given to a crossbow which already has "Multishot", and "Sharpness III" cannot be given to a sword which already has "Sharpness I")
if items in all targets' hand already have this enchantment Successful
On successAdds the specified enchantment to the item held by the target.

Output[edit]

CommandEditionSituationSuccess Count/execute store succeess .../execute store result ...
anyJava EditionOn fail000
On success11the number of players whose items are successfully enchanted.
Bedrock EditionOn fail0N/AN/A
On successthe number of players whose items are successfully enchanted.N/AN/A

Notes[edit]

  1. Although /enchant enforces maximum levels and compatibility, other commands (such as /give, /replaceitem, and /data) can bypass these restrictions.

Examples[edit]

  • To give the Infinity enchantment to all players holding a bow:
    /enchant @a infinity
  • To enchant the executing player's held sword with Sharpness 5:
    /enchant @s sharpness 5

History[edit]

This section needs expansion.
You can help by adding to it.
Java Edition
1.4.4preAdded /enchant.
1.1317w45aRemoved /enchant.
18w06aRe-added /enchant.
Pocket Edition Alpha
0.16.0build 5Added /enchant.