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, and rename items and blocks. Anvils are affected by gravity like sand, ignited TNT, dragon eggs and gravel. All their functions cost experience levels (more for enchanted items), and some have material costs as well.

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! Anvils can also use "units" of material (iron ingots, wooden planks, pieces of leather, etc.) to repair tools and swords made of that material. On heavily damaged tools, more than one piece of material may be required; 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 plus (+) 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.

Falling anvils
If there is no block below an anvil, it will fall. An anvil will make a metal-like 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.

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)%

Bugs

 * When anvils are dropped on a bed, you can still sleep on it.
 * If you place a renamed block or give a renamed item to a zombie and then reclaim it, the block or item will lose its name.
 * Anvils can be pushed by pistons if the anvil is falling.
 * Anvils can duplicate items.
 * If you delete the whole name of an object to be combined and attempt to craft it, your levels will be spent with no item created.

Trivia

 * It takes a total of 31 iron ingots to craft an anvil.
 * Similarly to obsidian, bedrock and End Portal Frames, anvils cannot be pushed or pulled by pistons.
 * The anvil has the same blast resistance as obsidian and 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 amount of damage caused by falling anvil.
 * If you drop an item from a renamed stack of items it will no longer stack, even with more items with the exact same name.
 * 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.