Anvil

An anvil is a block that allows players to repair items, rename items, and combine enchantments.

Breaking
Anvils can be mined using any pickaxe. If mined without a pickaxe they drop nothing.

Natural generation
A damaged anvil generates in the "Forge room" of the woodland mansion.

Crafting
A total of 31 iron ingots (including 27 for three blocks of iron) are required to craft an anvil.

Repairing and renaming items
Anvils have two modes to repair items that have a durability rating:
 * As with the grindstone, a player may repair items by combining two similar items. With the anvil, however, the target retains its enchantments and may gain new ones from the sacrificed items.
 * Alternatively, a player can use materials originally required in the crafting of the item (iron ingots for iron items with durability, diamonds for diamond items with durability) to repair a single item. One material can repair 25% of the target's maximum durability. This is a very good deal in the case of a chestplate, for example; a full repair (four materials) would total only half of the item's original cost (eight materials). In the case of tools and weapons, however, this may be a significantly less economical option; combining two diamond shovels would cost two diamonds in total, while up to four diamonds could be required to directly repair one. Still, it may be worth making the more expensive upgrade if the enchantments are considered difficult to obtain.

In addition, the player can rename any item - not just items with durability - by using an anvil.

Repairing


Repairing with materials works for the most part, but not with all items: in general, repairing works for items with their material in the default name. For example, an anvil can repair an iron pickaxe with materials (iron in this case) while an anvil cannot repair bows or shears except with other bows or shears. As a special case, chain armor can be repaired with iron ingots, turtle shells can be repaired with scutes, and elytra can be repaired with phantom membranes. The repair does not need to be complete; one material repairs $1/4$ of the item's maximum durability.

Repairing with a matching item works for any item with durability including bows, shears and so on. The items must be a matching tool and of a matching material. For example, a golden pickaxe cannot combine with a golden sword or iron pickaxe.

Note that in both cases the resulting durability is limited to the item's maximum, and there is no discount for "over-repair".

As a subset of repairing one item with another, the anvil can transfer enchantments from the sacrifice to the target. This can have a synergistic effect when both items share identical enchantments, or simply add to each other when they do not. Two Sharpness II swords can be combined to make a Sharpness III sword, for example, or a pickaxe with Efficiency can be combined with one that has Unbreaking. This can produce enchantments and combinations that are not possible with an enchanting table. But even so, some enchantments cannot be combined if they are similar, or contradicting, in terms of what they do. If the target is damaged, the player has to pay for the repair as well as the transfer.

Transferring high-level enchantments is more expensive, and renaming an item has an additional surcharge. The anvil has a limit of 39 levels; beyond that, repairs are refused. This limit is not present in Creative mode.

Every time armor or tools are repaired, the minimum experience cost doubles (e.g., 1 level, 2 levels, 4 levels, 8 levels, etc.).

Renaming
Any item or stack of items can be renamed at a cost of one level plus any prior-work penalty. If the player is only renaming, the maximum total cost is 39 levels. The maximum length for renaming is 35 characters / 50 characters. Some items have special effects when renamed:
 * A name tag must be renamed before it can be used.
 * Renaming a bucket of fish names the fish inside as well, meaning a fish can be named without a name tag.
 * A renamed item (can be any item, doesn't need to be a weapon) that kills another player or tamed mob causes the name to appear in the death message.
 * A renamed spawn egg produces a mob with the same name.
 * Chests, trapped chests, shulker boxes, furnaces, hoppers, droppers, dispensers, minecarts with chests, minecarts with hoppers, enchantment tables, barrels, smokers, blast furnaces and brewing stands display the name in their GUI when placed.
 * Renamed command blocks use their name in chat messages instead of.

Any name changes to items are applied to the data tag. Similarly this data tag can be accessed by the  argument using target selectors.

Enchanted books
Enchanted books are used to enchant tools. Enchanted books themselves can be combined to create higher-tiered books. This makes an anvil the alternative to an enchantment table.

Falling anvils
When there is no supporting block below an anvil, the anvil falls in the same way sand, gravel, concrete powder, and dragon eggs fall. A placed anvil cannot be pushed or pulled by pistons, but a falling anvil can be pushed (though cannot be pulled), as it is an entity. This is different $$ where anvils can be pushed and pulled by pistons. Anvils make a metallic clang sound when they land.

A falling anvil damages any player, mob or item that it falls on. The damage amount depends on fall distance: per block fallen after the first (e.g., an anvil that falls 4 blocks deals  damage). The damage is capped at, no matter how far the anvil falls. Wearing a helmet reduces the damage by $1/4$, but this costs durability on the helmet. When a player dies by an anvil falling on them, the death message " was squashed by a falling anvil" appears. However, if a player is merely touched by a falling anvil entity, no damage is dealt unless the falling anvil becomes an anvil block in the same block where the player is located.

If an anvil falls onto a block with a solid top surface, but the same block it is in cannot be replaced (torch, slab, etc.), it breaks and drops as an item.

An anvil that falls for 3 blocks and longer destroys any item entity it lands on.

Maps
$$, an anvil can be used instead of a crafting table to zoom a map out, to clone a map, or to place a player position marker on a map. However, with the introduction of the cartography table, this feature became dispensable.

Becoming damaged
With each use, an anvil has a 12% chance to become damaged – degrading one stage at a time, first becoming chipped, then damaged, then eventually destroyed. An anvil typically survives for 25 uses on average or approximately one use per 1.24 iron ingots used in crafting the anvil.

An anvil can be damaged and destroyed from falling. If it falls from a height greater than one block, the chance of degrading by one stage is 5% × the number of blocks fallen.

The damage state does not affect the anvil's function, but only anvils of the same damage state can stack in inventory.

ID




Metadata
$$, anvils use the following data values:

Trivia

 * If an item is renamed, such as diamonds, it cannot stack with unnamed or differently-named items.
 * 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 players can use less material at the cost of experience levels.
 * If placed on top of exploding TNT blocks, the explosion does not 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.
 * $$, any item can be enchanted with the anvil in Creative mode.