Anvil

An Anvil is a block that uses the item repair interface to repair and rename items, and combine enchantments. The anvil uses a complex XP cost system, where the way the tools are positioned and how many times they are repaired affect their cost. For full details, see anvil mechanics.

Usage
Anvils can be used to repair tools and armor, enchant items with enchanted books, and rename items and blocks. Anvils are affected by gravity like sand, gravel, and dragon eggs: If the block under them is removed, or if they are placed over open space, they will fall. A placed anvil cannot be pushed or pulled by pistons, but a falling anvil (entity) can. A falling anvil can do considerable damage to mobs or players, so they can also be used in traps.

All their functions cost experience levels and some have material costs as well. Anvils are damaged by both normal use and falling and will eventually be destroyed by such use.

Repairing and renaming
Anvils have two modes of repair. They can combine two items like the crafting grid, but the target will keep its enchantments, and may gain new ones from the sacrificed item. A player can also use materials like leather and iron ingots to repair tools and armor; each represents 25% of the item's maximum durability. The player can also rename any item - not just tools or armor - using an anvil. Renaming an item removes the penalty paid for repairing the same item multiple times. With each use anvils have a 12% chance to be damaged. Once expended the GUI will close and the anvil will disappear dropping the forged item on the ground.

How to repair
Place the "input" item on the left slot. On the right, place either a matching item (the "sacrifice"), or one or more pieces of the item's raw material. The anvil will then tell you how many levels this repair will cost. Repairing with materials only works for items with their material in the default name, e.g. Iron Pickaxe. Chain armor can be repaired with iron ingots. Repairing with a matching item works for any item with durability including bows, shears and so on. The repair need not be complete; each unit of material will repair 25% of the item's maximum durability. When sacrificing an item for repair, the sacrifice's remaining durability will be added to the target, along with a bonus of 12% of the item's durability. Note that you pay levels per unit of material, or according to the sacrifice durability, with no discount for "over-repair".

As a subset of repairing one item with another, the anvil can transfer enchantments from the "sacrifice" item to the target. Two Sharpness II swords can be combined with a Sharpness III sword, or a pick with Efficiency can be combined with one that has Unbreaking. This can produce enchantments and combinations that could not be made at an enchanting table but even so, some enchantments cannot be combined (such as Sharpness and Smite). Also, the items must match in type: you cannot combine a golden pickaxe with an iron one. If the target is damaged, you will pay for the repair as well as the transfer.

Work on items with expensive materials (diamond) or many / high-level enchantments is more expensive. Transferring enchantments can add even more cost, and renaming an item has an additional surcharge. To boot, repeatedly repairing an item gives a cumulative penalty (which can be avoided by renaming the item). Unfortunately the anvil has a limit of 39 levels, beyond which it will refuse the job altogether. This limit is not present in Creative mode. In some cases it may be possible to do things piecewise (rename, repair, then transfer enchantments) but some items may just be too expensive to work with. For full details of the anvil's costs and restrictions, see the Anvil mechanics page.

Renaming
Any item or stack of items can be renamed at a cost of seven levels if the item is a tool and five levels otherwise. Renamed tools and renamed mobs (from renamed spawn eggs) will show in death messages. Renamed mobs will show their name when your cursor is on them. Renamed command blocks will use their name instead of "@".

Enchanted books
Enchanted books are used with an anvil to enchant an item with the book acting as the sacrifice (second slot). Enchanted books themselves can be combined to create higher-level books. They cannot be combined to make books with multiple enchantments. The regular enchanting rules still apply but with significant discount to the cost. In Creative mode any item can be enchanted this way (e.g., a Silk Touch Stick), but even then, incompatible enchantments may not be combined.

Falling anvils
If there is no block below an anvil it will fall. An anvil will make a metallic clanging sound when it lands.

When an anvil lands on a non-solid block like a torch or rail it will destroy that item instead of dropping it. When dropped on a pressure plate, a boat, cobwebs, a slab, a sign, a cake, a lily pad, closed trapdoor or opened fence gate, the anvil will drop as an item. When dropped on a flower pot, the flower pot is destroyed without a drop. When dropped on a trophy head decoration, the head is dropped as an item.

A falling anvil will also damage mobs and players. Damage amount depends on fall distance: × MIN(Distance × 2, 10). Wearing a helmet will reduce the damage by 45%. A player dying by an anvil falling on them will receive this message: "player was squashed by a falling anvil." However if a player is touched by an anvil entity, or falling anvil, no damage will result until the anvil becomes a block in the gridspace where the player is. So anvils can be shot with a TNT Cannon, and pass right through a player, and not damage them. In addition, if the player jumps at the correct time, the player will not be in the gridspace where the anvil is, negating player damage; however, this can be difficult.

An anvil has a chance to be damaged by the fall. Damage chance also depends on fall distance and is equal to (5 + Distance*5)%

Trivia

 * If a block is renamed it will not keep its name after being placed.
 * It takes a total of 31 iron ingots to craft an anvil.
 * The falling ability of the anvil is a reference to the common cartoon trope.
 * The anvil has the same blast resistance as obsidian and the enchantment table.
 * If you rename a material, such as diamonds, it will not stack with unnamed or differently-named items.
 * An anvil will last about 25 uses on average.
 * Armor reduces the amount of damage caused by falling anvils.
 * The high blast resistance and transparency of the block makes for a good blast-proof window.
 * If a falling anvil lands on a pressure plate, it will damage any mob standing on the pressure plate, and drop as an item.
 * For unenchanted items, "unit repair" can easily cost more material than just crafting a new item or combining damaged items. The exception is armor, where you can use less material at the cost of experience levels.  Also, the choice between unit repair and sacrifice repair depends very much on the details (how damaged is the target, and the proposed sacrifice?  How many enchantments?), especially when dealing with diamond items.
 * If placed on top of exploding TNT blocks, the explosion won't affect the surrounding area.
 * This is because the Anvil falls into the space the TNT entity is occupying, and since the TNT's explosion power is not high enough to destroy the anvil, no blocks are destroyed.
 * If an anvil falls 13 blocks, it will become slightly damaged.
 * If a slightly damaged anvil falls 5 blocks, it will become very damaged.
 * If a very damaged anvil falls 5 blocks, it will break.
 * Anvils are also commonly used as a guillotine because of its ability to kill mobs/players as a controlled entity.
 * No action sounds are given while stepping on or jumping on an anvil.
 * If an anvil is placed on top of a chest, you are still able to open it.