# Applying Enchantments This page explains how enchantments get onto items, and the rules you can add on top of the vanilla ones: - [Dragging a book onto an item](#dragging-a-book-onto-an-item), optionally with a [price](#price). - Enchantments that [need another one first](#requires-enchantments-that-must-be-there-first), or that [upgrade another one](#replaces-upgrades). - A [maximum number of enchantments per item](#maximum-enchantments-per-item), and a maximum per [type](Types). - Changes to the [anvil](#the-anvil), the [grindstone](#the-grindstone) and the [enchanting table](#the-enchanting-table). ## The same rules everywhere The rules on this page are checked by **every** way of putting enchantments on an item that players use: dragging books, the anvil and the enchanting table. That way a player cannot get around a limit by using the anvil instead of a book. They are checked in this order: 1. The item accepts the enchantment (`supported-items`). Books accept everything. 2. It is not [incompatible](Items-Slots-And-Incompatibilities#incompatible-enchantments) with an enchantment already on the item. Enchantments it [`replaces`](#replaces-upgrades) do not count. 3. The level is not already the highest. 4. The enchantments it [`requires`](#requires-enchantments-that-must-be-there-first) are on the item. 5. The item is under the [maximum number of enchantments](#maximum-enchantments-per-item). 6. The item is under the maximum of the enchantment's [type](Types). Books are not limited by 5 and 6: a book can hold any number of enchantments. The limits apply when the book is put on an item. Administrator commands do not apply the MetaEnchants-only rules (`requires`, the per-item limit and the type limit). The game still enforces item support and incompatibility for `/enchant` and `/forceenchant`, and `/forceenchant` ignores the maximum level. `/metaenchants apply` follows every rule on this page. ## Dragging a book onto an item Players can apply a book without an anvil: 1. Open the inventory. 2. **Pick up** the book with the mouse. 3. **Click** it on the item. If everything is right, the item gets the enchantment, the book is used, and the player hears the enchanting sound. If not, nothing changes, the book stays on the mouse, and the player reads why: > This item has Sharpness V, which does not work with this book. How the level works, like in the anvil: | The item has | The book has | Result | |---|---|---| | Nothing | Vampirism II | Vampirism II | | Vampirism II | Vampirism II | Vampirism III (one level up, if below the maximum) | | Vampirism II | Vampirism IV | Vampirism IV | | Vampirism IV | Vampirism II | Refused: the item already has a better level. | A book with several enchantments applies all of them, or none if one is refused. Turn it on or off for the whole server in `config.yml`: ```yaml apply: drag-and-drop: true ``` and for one enchantment in its file: ```yaml drag-and-drop: false ``` When an enchantment does not allow it, its books behave as in vanilla: clicking swaps the book and the item. It works on items in the player's own inventory, also while a chest or another container is open. It does not work in the creative inventory screen, or on items inside containers and menus of other plugins. ### Price An enchantment can cost something to apply by dragging. Write it in the enchantment file: ```yaml price: money: 100 levels: 3 items: ["DIAMOND 2", "EMERALD"] per-level: true ``` | Option | What it costs | |---|---| | `money` | Money from the player's balance (needs Vault and an economy plugin). | | `levels` | Experience levels. | | `exp` | Experience points, for prices smaller than a level. | | `items` | Items from the inventory, written as `MATERIAL amount`. The amount can be left out for 1. | | `per-level` | `true` multiplies the whole price by the level of the book. | With the example above, a level III book costs 300 money, 9 levels, 6 diamonds and 3 emeralds. If the player cannot pay all of it, nothing is taken and they read what they need. Players in creative mode do not pay. The price is paid even if the book then [fails](Books#success-and-destroy-rates). ## `requires`: enchantments that must be there first ```yaml requires: vampirism: 2 minecraft:sharpness: 1 ``` This enchantment can only go on items that already have Vampirism II or higher **and** Sharpness I or higher. Write each enchantment with the level it needs at least. MetaEnchants enchantments can be written without `metaenchants:`; vanilla ones need `minecraft:`. A list means level 1 is enough: ```yaml requires: [vampirism, minecraft:sharpness] ``` The anvil and the enchanting table follow it too: they will not produce an item that has this enchantment without the ones it requires. ## `replaces`: upgrades ```yaml replaces: [swiftness] ``` When this enchantment is put on an item, the enchantments in `replaces` are **removed**. It is the way to make upgrades: *Super Speed* replaces *Swiftness*, so the player does not need to remove one before adding the other, and the two are never on the same item. `replaces` is applied when dragging books and with `/metaenchants apply`. ## Maximum enchantments per item ```yaml apply: max-enchants: 5 count-vanilla: true ``` - `max-enchants`: the most enchantments one item can have. `0` means no limit. - `count-vanilla`: `true` counts vanilla enchantments too. `false` only counts MetaEnchants enchantments. Give some players another limit with the permission `metaenchants.limit.`. A player with `metaenchants.limit.8` can have 8 enchantments per item, whatever `max-enchants` says. With several of these permissions, the highest wins. [Orbs](Special-Items#orbs-extra-enchantment-slots) add extra slots to one item on top of that limit: an item with two orbs used on it can have `max-enchants` + 2. ## The anvil The anvil follows the rules above: if the result would break them, the anvil shows no result. It also has its own settings in `config.yml`: ```yaml anvil: max-cost: 40 cost-multiplier: 1.0 rework-penalty: true color-renames: false ``` | Option | What it does | |---|---| | `max-cost` | The anvil says *Too Expensive!* when the cost reaches this. Vanilla is 40; a bigger number lets players keep combining. | | `cost-multiplier` | Multiplies every cost. `0.5` makes the anvil half price; `2` doubles it. | | `rework-penalty` | In vanilla, every anvil use makes the next one on the same item more expensive. `false` turns that off. | | `color-renames` | Lets players with `metaenchants.anvil.color` use colors when renaming, like `Excalibur` or `Excalibur`. Only colors and styles work, not clicks or other tags. | The anvil does not use [success and destroy rates](Books#success-and-destroy-rates). ## The grindstone The grindstone removes enchantments, except curses. You can protect others: - In a [type](Types): `grindstone: false` protects every enchantment of that type. - In an enchantment file: `removable: false` protects that enchantment, whatever its type says. `removable: true` lets the grindstone remove it, even if its type says otherwise. - For vanilla enchantments, in [`vanilla.yml`](Vanilla-Enchantments). ```yaml removable: false ``` A protected enchantment stays on the item that comes out of the grindstone. ## The enchanting table When the table rolls enchantments, MetaEnchants can change the result before it is given: - Each MetaEnchants enchantment can have a [chance](Where-Enchantments-Appear#chances) to really be given, and a [minimum level cost](Where-Enchantments-Appear#minimum-table-level). - Its [type](Types) can make lower levels more common. - The rules on this page are applied: a rolled enchantment that is missing its `requires`, or that goes over a limit, is left out. - `config.yml` can give fewer enchantments per roll. See [Where Enchantments Appear](Where-Enchantments-Appear#fewer-enchantments-per-roll). If everything rolled is left out, the player still gets one enchantment (preferably a vanilla one), so the table never takes their levels for nothing. ## Commands | Command | What it does | |---|---| | `/metaenchants apply [level]` | Puts the enchantment on the item in your hand, following all the rules on this page (without price or rates). | | `/metaenchants item` | Opens the menu with only the enchantments that the item in your hand accepts. | See [Commands and Permissions](Commands-And-Permissions). ## In short - Players apply books by clicking them on items; `apply.drag-and-drop` and `drag-and-drop` turn it on and off. - `price` makes applying cost money, levels or items. - `requires` and `replaces` build chains of enchantments. - `max-enchants` and `metaenchants.limit.` limit enchantments per item; [types](Types) limit them per kind. - The anvil, the grindstone and the enchanting table follow the same rules.