enchant
Add an enchantment to a target or to some targets (players).
The enchantment is added to the tool that the target player has now. If the target’s current tool (or other item they have) is not enchantable, then the enchantment won’t work and it isn’t added.
mobs.enchant(mobs.target(LOCAL_PLAYER), "infinity", 1);
Parameters
- target: a target selector that determines which players (targets) will get the enchantment
- spell: the code name of the enchantment, like: “infinity”
- level: the strength level of the enchantment, such as: 1
A summary of enchantments, including their effect and their maximum level, is in the Minecraft wiki.
The names of the enchantments are in the this section of the Minecraft wiki. Look in the column labeled “name”.
Example
Enchant the tool that current player has so it lasts longer.
mobs.enchant(mobs.target(LOCAL_PLAYER), "unbreaking", 3);