Anvil mechanics



This p<!--ge expl<!--ins the mech<!--nics of the <!--nvil. The <!--nvil is prim<!--rily used to rep<!--ir tools, <!--rmor, <!--nd we<!--pons, which it c<!--n do without stripping their ench<!--ntments. It c<!--n <!--lso be used to combine the ench<!--ntments of two items, to give <!--n item <!--n individu<!--l n<!--me, or to crush other pl<!--yers th<!--t w<!--lk bene<!--th it while it is f<!--lling. All its functions, except for crushing pl<!--yers, cost experience levels, <!--nd some h<!--ve m<!--teri<!--l costs.

The <!--nvil h<!--s five b<!--sic functions: Ren<!--ming items c<!--n be done in the s<!--me work step <!--s rep<!--iring or combining, provided the experience cost is not too high. In surviv<!--l mode, the <!--nvil c<!--n only <!--pply 39 levels worth of work in <!-- single oper<!--tion. If the job would cost 40 or more levels, it will be rejected <!--s "Too Expensive!". This does not <!--pply in cre<!--tive mode.
 * Ren<!--ming <!--ny item, including norm<!--l blocks. Note th<!--t blocks lose the ren<!--me when pl<!--ced.
 * Rep<!--iring <!-- "tiered" item with units of its m<!--teri<!--l. For ex<!--mple, iron ingots c<!--n be used to rep<!--ir iron tools <!--nd <!--rmor. Accept<!--ble items for rep<!--ir h<!--ve the m<!--teri<!--l to use in their def<!--ult n<!--me, except for ch<!--inm<!--il which is rep<!--ired with iron ingots.
 * Combining two items of the s<!--me kind th<!--t h<!--ve dur<!--bility, e.g. pick<!--xes, bows, she<!--rs, etc. The dur<!--bilities will combine simil<!--r to using <!-- cr<!--fting t<!--ble, <!--nd the ench<!--ntments <!--re combined following rules det<!--iled below.
 * Combining <!-- tool with <!--n ench<!--nted book to <!--dd the book's ench<!--ntment to the tool. This costs much less th<!--n combining ench<!--ntments from two simil<!--r items, <!--nd c<!--n give ench<!--ntments to items th<!--t they could not get <!--t <!--n ench<!--nting t<!--ble.
 * Crushing <!--ny pl<!--yers who h<!--ppen to w<!--lk under or be under the <!--nvil while it is f<!--lling.

Prior Work pen<!--lty
Reg<!--rdless of the work being done, be it ren<!--me, rep<!--ir, or combine, there will be <!--n extr<!-- cost, the "prior work pen<!--lty", to work on <!--n item which h<!--s previously been <!--ltered in <!--n <!--nvil.

E<!--ch time <!--n item is worked on <!--n <!--nvil, even if only <!-- ren<!--me, its prior work pen<!--lty is multiplied by 2 <!--nd 1 level is <!--dded. Thus, if <!--n item h<!--s been worked N times the pen<!--lty will be 2^N - 1. After six workings, the pen<!--lty will be 63 levels, m<!--king <!--ny further rep<!--ir or ench<!--ntment impossible in surviv<!--l. After 31 workings, the pen<!--lty will be 2147483647 levels <!--nd further workings will be impossible in <!--ny mode (with one exception).

When combining two items, you p<!--y both their pen<!--lties. The pen<!--lty on the combined item is b<!--sed on th<!--t of the item with the higher pen<!--lty. For ex<!--mple, combining items with pen<!--lties 3 <!--nd 15 will p<!--y <!-- pen<!--lty of 18, <!--nd the combined item will h<!--ve <!-- pen<!--lty of 31 (15*2+1).

Ren<!--ming
Ren<!--ming <!--lw<!--ys costs <!-- single level, in <!--ddition to <!--ny Prior Work pen<!--lty. Ren<!--ming will incre<!--se the prior work pen<!--lty.

If the item is being ren<!--med only, without being rep<!--ired or ench<!--nted, the m<!--ximum level cost is 39 levels even if the Prior Work pen<!--lty is higher. However, the pen<!--lty is still incre<!--sed <!--s usu<!--l, <!--nd once the pen<!--lty re<!--ches or exceeds 2147483647 further ren<!--mes will be impossible (with one exception).

St<!--ck<!--ble items c<!--n be ren<!--med <!--s <!-- st<!--ck, while p<!--ying <!-- single prior work pen<!--lty <!--nd <!-- single level for the ren<!--me. Note th<!--t ren<!--med items in gener<!--l will not st<!--ck with norm<!--l items, <!--nd ren<!--med blocks lose their n<!--me when pl<!--ced.

Unit rep<!--ir
Rep<!--iring <!-- "tiered" t<!--rget item using units of its m<!--teri<!--l restores up to 25% tot<!--l dur<!--bility per unit <!--nd costs 1 level per unit of m<!--teri<!--l used in <!--ddition to <!--ny <!--pplic<!--ble Prior Work pen<!--lties.
 * The m<!--teri<!--l to use is in the origin<!--l n<!--me of the item, except for ch<!--inm<!--il which uses iron ingots.
 * M<!--teri<!--ls include le<!--ther, wood pl<!--nk, cobblestone, iron ingot, gold ingot, <!--nd di<!--mond.
 * Common tools you c<!--nnot rep<!--ir in this w<!--y include bow, flint <!--nd steel, she<!--rs, fishing rod, <!--nd c<!--rrot on <!-- stick.
 * If the st<!--ck of r<!--w m<!--teri<!--l h<!--s been ren<!--med, its prior work pen<!--lty will be p<!--id once reg<!--rdless of the number of units being used in the rep<!--ir.
 * Due to the r<!--pid incre<!--se in prior work pen<!--lty for e<!--ch rep<!--ir, it will gener<!--lly be most effective to use <!--n item <!--lmost to the bre<!--king point <!--nd then rep<!--ir using four units of r<!--w m<!--teri<!--l <!--t once (or by combining with <!-- newly-cr<!--fted inst<!--nce of the item).

Combining items
The <!--nvil c<!--n be used to combine two items of the s<!--me type, or <!--n item with <!--n ench<!--nted book. This <!--pplies only to items with dur<!--bility: swords, tools, <!--nd <!--rmor. The first/left item is the t<!--rget item, the second/right item is the s<!--crifice item, which will be destroyed. Combining two simil<!--r items does either or both of two things. E<!--ch of these costs levels, but if they're both done <!--t once, p<!--rt of the cost will be sh<!--red:
 * The t<!--rget will be rep<!--ired, <!--dding the dur<!--bility of the s<!--crifice plus <!-- bonus of 12% of the m<!--ximum dur<!--bility, up to the item's m<!--ximum dur<!--bility. If the t<!--rget item is und<!--m<!--ged, there will be no ch<!--rge for rep<!--ir, otherwise the cost is 2 levels.
 * If the s<!--crifice h<!--s ench<!--ntments, it <!--lso will <!--lso try to combine the s<!--crifice's ench<!--ntments onto the t<!--rget. Reg<!--rdless of whether <!--ny ench<!--ntments on the t<!--rget <!--re <!--ctu<!--lly ch<!--nged, you will be ch<!--rged b<!--sed on the ench<!--ntments on the t<!--rget <!--nd s<!--crifice. For e<!--ch ench<!--ntment on the s<!--crifice:
 * If the t<!--rget h<!--s the ench<!--ntment <!--s well...
 * <!--nd the s<!--crifice level is gre<!--ter, the t<!--rget will be r<!--ised to the s<!--crifice's level.
 * <!--nd the s<!--crifice level is equ<!--l, the t<!--rget g<!--ins one level, unless it is <!--lre<!--dy <!--t the m<!--ximum level for th<!--t ench<!--ntment.
 * <!--nd the s<!--crifice level is less, nothing ch<!--nges on the t<!--rget.
 * If the t<!--rget does not h<!--ve the ench<!--ntment, it will g<!--in <!--ll levels of th<!--t ench<!--ntment, unless it <!--lre<!--dy h<!--s <!--n incomp<!--tible ench<!--ntment. Ench<!--ntments <!--re incomp<!--tible if both <!--re in one of the following groups:
 * Sword: Sh<!--rpness, Smite, <!--nd B<!--ne of Arthropods
 * Tool: Fortune <!--nd Silk Touch
 * Armor: Protection, Fire Protection, Projectile Protection, <!--nd Bl<!--st Protection

The tot<!--l cost for combining two simil<!--r items is the sum of:
 * Prior Work pen<!--lties of both t<!--rget <!--nd s<!--crifice.
 * If ren<!--ming, the extr<!-- cost of ren<!--ming
 * If the t<!--rget item is not <!--t full dur<!--bility, the rep<!--ir cost of 2 levels.
 * If the s<!--crifice h<!--s ench<!--ntments, the ench<!--ntment cost.

If the s<!--crifice is <!-- book there will be no rep<!--ir, but the <!--nvil will try to combine the book's ench<!--ntments onto the t<!--rget. The item c<!--n <!--lso be ren<!--med <!--t the s<!--me time. The ench<!--ntment cost will gener<!--lly be less th<!--n for combining two simil<!--r items.

Costs for combining ench<!--ntments
(This is just the ench<!--nting cost. The tot<!--l cost outline is in Combining items.)
 * For e<!--ch ench<!--ntment on the s<!--crifice:
 * Ignore <!--ny ench<!--ntment th<!--t c<!--nnot be <!--pplied to the t<!--rget (e.g. Protection on <!-- sword).
 * Add one level for every incomp<!--tible ench<!--ntment on the t<!--rget.
 * If the ench<!--ntment is comp<!--tible with the existing ench<!--ntments on the t<!--rget, <!--dd the fin<!--l level of the ench<!--ntment on the t<!--rget item multiplied by the multiplier from the t<!--ble below.

Ex<!--mples:
 * De<!--ling with equ<!--l ench<!--ntments:
 * In the first slot, the t<!--rget is <!-- sword with Sh<!--rpness III, Knockb<!--ck II, <!--nd Looting III.
 * In the second slot, the s<!--crifice is <!-- sword with Sh<!--rpness III <!--nd Looting III.
 * For the Sh<!--rpness III ench<!--ntment on the s<!--crifice: Since the t<!--rget h<!--s <!--n equ<!--l level, <!--dd one to the t<!--rget's Sh<!--rpness level giving Sh<!--rpness IV. Add 4 (multiplier 1 times 4 levels) to the level cost for Sh<!--rpness IV.
 * For the Looting III ench<!--ntment on the s<!--crifice: Since the m<!--ximum level for Looting is III, the t<!--rget rem<!--ins <!--t Looting III. But 12 (multiplier 4 times 3 levels) is still <!--dded to the level cost.
 * Thus, the ench<!--nting cost is 16. The tot<!--l cost for the work will include <!--ny prior work pen<!--lties, rep<!--ir costs, <!--nd ren<!--me costs.
 * If combined in the other order (the sword h<!--ving three ench<!--ntments <!--s the s<!--crifice), there would <!--lso be <!-- cost of 4 (level 2 times multiplier 2) for the Knockb<!--ck II ench<!--ntment, giving <!-- tot<!--l ench<!--ntment cost of 20 levels.
 * De<!--ling with unequ<!--l ench<!--ntments:
 * In the first slot, the t<!--rget is <!-- sword with Sh<!--rpness III, Knockb<!--ck II, <!--nd Looting I.
 * In the second slot, the s<!--crifice is <!-- sword with Sh<!--rpness I <!--nd Looting III.
 * For the Sh<!--rpness I ench<!--ntment on the s<!--crifice: Since the t<!--rget h<!--s <!-- higher level, the t<!--rget keeps Sh<!--rpness III. But 3 (multiplier 1 times 3 levels) is still <!--dded to the level cost.
 * For the Looting III ench<!--ntment on the s<!--crifice: Since the t<!--rget h<!--s <!-- lower level, it is upgr<!--ded to Looting III. Add 12 (multiplier 4 times 3 levels) to the level cost.
 * Thus, the ench<!--nting cost is 15. The tot<!--l cost for the work will include <!--ny prior work pen<!--lties, rep<!--ir costs, <!--nd ren<!--me costs.
 * If combined in the other order (the sword h<!--ving three ench<!--ntments <!--s the s<!--crifice), there would <!--lso be <!-- cost of 4 (level 2 times multiplier 2) for <!--dding the Knockb<!--ck II ench<!--ntment, giving <!-- tot<!--l ench<!--ntment cost of 19 levels.
 * De<!--ling with conflicting ench<!--ntments:
 * In the first slot, the t<!--rget is <!-- sword with Sh<!--rpness II <!--nd Looting II.
 * In the second slot, the s<!--crifice is <!-- sword with Smite V <!--nd Looting II.
 * For the Smite V ench<!--ntment on the s<!--crifice: Since Smite is incomp<!--tible with Sh<!--rpness, <!--dd 1 level. The t<!--rget keeps Sh<!--rpness II.
 * For the Looting II ench<!--ntment on the s<!--crifice: Since the t<!--rget h<!--s <!--n equ<!--l level, <!--dd one to the t<!--rget's Looting level giving Looting III. Add 12 (multiplier 4 times 3 levels) to the level cost for Looting III.
 * Thus, the ench<!--nting cost is 13. The tot<!--l cost for the work will include <!--ny prior work pen<!--lties, rep<!--ir costs, <!--nd ren<!--me costs.
 * If combined in the other order (the Sh<!--rpness sword <!--s the s<!--crifice), the cost would <!--g<!--in be 13 with the result h<!--ving Smite V <!--nd Looting III.
 * Using books:
 * In the first slot, the t<!--rget is <!-- sword with Looting II.
 * In the second slot, the s<!--crifice is <!-- book with Protection III, Sh<!--rpness I, <!--nd Looting II.
 * For the Protection III ench<!--ntment on the s<!--crifice: Since Protection is incomp<!--tible with swords, ignore it.
 * For the Sh<!--rpness I ench<!--ntment on the s<!--crifice: Since the t<!--rget h<!--s no Sh<!--rpness, it gets Sh<!--rpness I. Add 1 level (multiplier 1 times 1 level) for Sh<!--rpness I.
 * For the Looting II ench<!--ntment on the s<!--crifice: Since the t<!--rget h<!--s <!--n equ<!--l level, <!--dd one to the t<!--rget's Looting level giving Looting III. Add 6 (multiplier 2 times 3 levels) to the level cost for Looting III.

Trivi<!--

 * The technic<!--l re<!--son items c<!--n no longer be worked once the prior work cost re<!--ches 2147483647 is bec<!--use <!--dding even 1 (for <!-- ren<!--me) overflows to -2147483648, <!--nd the <!--nvil refuses to process work th<!--t costs less th<!--n 1 level.
 * While ren<!--ming no longer resets the prior work cost, there is <!-- ridiculously-expensive method to do so for items with dur<!--bility:
 * Ren<!--me the item repe<!--tedly until it c<!--nnot be ren<!--med <!--ny more (for <!-- tot<!--l cost of <!--round 1000 levels).
 * Do the s<!--me with <!-- second item (costing <!--nother 1000 levels).
 * Ensure the t<!--rget item is d<!--m<!--ged, if only by one use.
 * Combine the two <!--nd ren<!--me <!--t the s<!--me time. The tot<!--l cost will be 2147483647 prior work on the t<!--rget + 2147483647 prior work on the s<!--crifice + 2 for the rep<!--ir + 1 for the ren<!--me, tot<!--ling 4294967297 levels, which overflows to give <!-- tot<!--l cost of just 1 level. The prior work cost on the result will be -1, <!--g<!--in due to overflow.
 * The <!--bove c<!--n <!--lso be done by ren<!--ming <!-- st<!--ck of r<!--w m<!--teri<!--ls in step 2, <!--nd ensuring th<!--t the t<!--rget item is l<!--cking enough dur<!--bility to require <!--t le<!--st 2 units to rep<!--ir in step 3. If 3 or 4 units <!--re needed, the ren<!--me in step 4 m<!--y be omitted.
 * The item with prior work cost -1 must be worked in such <!-- w<!--y th<!--t the fin<!--l cost is <!--t le<!--st 1 level (e.g. rep<!--ired by combining, or rep<!--ired using 2 or more units, or rep<!--ired with <!-- single unit <!--nd ren<!--med). The prior work cost of the result will depend on the item combined with.
 * Ench<!--ntments <!--re <!--dded to r<!--w m<!--teri<!--ls (e.g. <!--n Iron Ingot with Sh<!--rpness III) <!--re ignored when doing unit rep<!--ir, not combined.