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.

Crafting
The anvil takes a total of 31 Iron Ingots to craft

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 (except falling) cost experience levels (more for enchanted items), and some have material costs as well. Anvils can be 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 sacrifice 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 reduces a penalty paid for repairing the same item multiple times.) On each use, anvils have a 12% chance to be damaged. On its last use, the GUI will close and the anvil will disappear, dropping the item on the ground.

How to repair
Use a damaged tool, place it to the left of the + sign. On the right, place either a matching item (enchanted or unenchanted), or one or more pieces of the item's material. The anvil will then tell you how many levels this repair will cost. Once finished, you will have a fully repaired item. Repairing with materials only works for items with their material in the default name, e.g. Iron Pickaxe. Repairing with a matching item works for any item with durability, including bows, shears, and so on.

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 to 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.

Note that level costs for both sorts of repairing get expensive for diamond items, and very expensive for heavily enchanted items. Transferring enchantments can add even more, and renaming an item has an additional surcharge. To boot, repeatedly repairing an item gives a cumulative penalty (which can be minimized by renaming the item). Unfortunately, the anvil has a limit of 39 levels, beyond which it will refuse the job altogether. (This limit is lifted in creative mode.) In some cases, it may be possible to do things piecewise (rename, then 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. It costs 5 levels if not a tool and 7 levels if it is a tool if it's the first time you have renamed it. In the newest snapshots, 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 can be used with an anvil to enchant an item, and you will know what enchantment the item will get. The item goes in the first slot, and the enchanted book goes in the second slot. In Creative Mode, any item can be enchanted this way.

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

When an anvil lands on a non-solid block (like torches, rails, etc.), it will destroy that item instead of dropping itself as an item like sand, gravel, and dragon eggs do. 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 re-named 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 without damaging itself.
 * For unenchanted items, "unit repair" can easily be more expensive than just repairing a tool in the crafting table. 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?), 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.
 * If you try to run on an anvil, it will slow you down, having the same effect as Soul Sand.