Anvil mechanics/Before 1.8



This page explains the mechanics of the anvil. This page focuses on combining enchantments on tools, swords, armor and bows.

Combining and repairing items
An anvil can combine two items of the same type, merging their enchantments (within certain limits). This will cost experience levels depending on both the items put in, and the item that results. The tables below assume that the items are fully repaired; if they are damaged, it will cost more. Also, if an item has previously been combined, there will be an additional penalty. There is also a separate mechanism for repairing single items by adding more of their base material, but it's unclear whether this invokes the penalty.

This is for items in general for the anvil (doesn't depend which slot you put it in).


 * 1) The material that the tool is made out of doesn't matter. A wooden sword with looting 3 and bane 4 will cost the same when you put it into an anvil as a diamond sword with the same enchantments.
 * 2) Adding two like enchantments will give you an enchantment of the next level, as long as it doesn't go over the cap (knockback 1 + knockback 1 = knockback 2, but looting 3 + looting 3 = looting 3 still, since there is no looting 4)
 * 3) When combining enchantments, the item in the first slot (left slot) will be the "target" item; that is the item that gets the enchantment. When the anvil process occurs, it takes the enchantments from the item in the second slot and adds them onto the item in the first slot. This also means that if a sword with sharpness 3 and looting 2 is in the first slot, and a sword with bane 2 and looting 2 in the second slot, the sword with sharpness will override the bane sword, giving the final sword sharpness 3 and looting 3. It also means, though, that if the order of the swords are switched (i.e. have bane in first slot and sharpness in second), the final sword would end up having bane 2 and looting 3.
 * 4) Every time an item is put through the anvil, 2 extra levels are added to it. This means that if a sharpness 4 sword is made using two sharpness 3 swords, it will cost 2 more levels than a 'pure' sharpness 4 sword would.
 * 5) The maximum level of items that can be put into an anvil is 40. Once past this, the anvil says it is too expensive and won't do anything to it. In creative, the amount of levels on an anvil is more than normal.
 * 6) The costs are different for the target item and the one that's combined with it.  Putting the more powerfully enchanted of the two items into the first slot, will make the result cost less.
 * 7) The order of the enchantments on a weapon doesn't matter. A sword with sharpness 4, fire 2 and knockback 1 will cost the same as a sword with knockback 1, sharpness 4 and fire 2

Slot and other costs
To find out the level cost of combining two items, various factors must be taken into account. For completely unused items, they can be found by adding the following values:
 * 1) The "first slot" cost for each enchantment of the item in the first slot. These vary with the level of the enchantment, with a base cost (that is, a cost for the first tier of the enchantment) and a constant cost between levels.
 * 2) A penalty for the number of enchantments on the first item. That is 1 for a single enchantment, 3 for two, 6 for three, or 10 levels for 4 enchantments.
 * 3) The "second slot" cost for each enchantment of the item in the second slot. These costs are constant for each enchantment type, but combining two enchantments that are at maximum level costs half*
 * 4) An additional penalty of 2 levels for each time either item has been combined in an anvil.

Note: While the cost for combining two enchantments at maximum level are half of the normal cost compared to the other levels, some enchantments (such as sharpness 5), which are in the game but cannot be gotten naturally anymore, you need to make the enchantment, which will make the cost an extra 2 levels (see point 4 above)

Tables
Here are the tables for each item. The first column (left most column) gives the title of the enchant. The middle column gives the base cost of that enchant (that is, having an item with that enchant being in the first slot), while the right most column gives the value for an item with that enchant in the second slot.

Bows
To calculate the total cost of an item, add up the cost of each enchantment on it using the middle column, then add a value from this table based on how many enchantments it has:

You can calculate the number of levels you need to add by finding the nth triangular number, where n is the amount of extra enchants on an item.

Note: Items marks with an (*) are ones that can not be gotten from an enchantment table (like sharpness 5). If one can get a pure enchantment like this, the values from the table (like 6 for sharpness 5) would be used, but since they have to be made, you have to add the amount of times it has been put in anvil before (see point 4 under section 'General Notes'). For example, to make a sharpness 5 using 2 pure sharpness 4 swords would cost 7 levels. If that sword is then put that into an anvil, instead of costing 6 levels for a pure sharpness 5 sword, it will cost 2 more levels than that, so 8 levels total. This means that for sharpness, efficiency and power 5, the minimum level in the anvil will be 8. This is the same for the items in the third column of the table

Example
Say we make a sword with sharpness 3, knockback 2 and looting 2. To calculate the level it will be when going into the anvil, one must use the tables from the first slot section. The base cost of sharpness 3 is 4, the base cost of knockback 2 is 5 and the base cost of looting 2 is 9. This sword has 2 extra enchantments on it, so by looking at the table above for the extra enchantments, it can be seen that we need to add an extra 3 levels to the cost. This means that when this sword is put it into the anvil, it should cost 4+5+9+3=21 levels. If another sword is then enchanted and gets sharpness 3 and looting 2 on it, these two items can be combined to get a sword with sharpness 4, looting 3 and knockback 2. To calculate how much this would cost, we need to look at the tables in the second slot section. To add sharpness 3 costs 2 levels, and to add looting 2 costs 8 levels. This means, that if the first sword is in the first slot, thus starting with the 21 levels from before, to add the sharpness 4 and looting 2 sword would cost 21+2+8=31 levels.

First sword in anvil. It costs 21 levels, as predicted



Second sword in the anvil



Final sword costing the amount predicted, with the enchantments predicted



Formulas
This section deals with some formulas for those who prefer formulas to tables. While there still are some tables in this section, they are very short and more centered to be used for the formulas:

Formulas
To find the level cost of an enchantment, one must use the following formula:

To find the level of the item in the first slot, you use:

LF=Bk+(nk-1)*Ik+E+2*A

Where:
 * LF is the total level of the first item
 * B is the base cost of the item
 * n is the tier of enchantment (sharpness 3 would be tier 3)
 * I is the increment value
 * E is the extra cost depending on the number of enchantments on the item
 * A is the amount of times the item has been through the anvil process

When there are subscript letters (such as Bk, nk or Ik), the k is there for each enchantment. For an item with only 1 enchantment, you would only need to add (n-1)*I, while for an item with 4 enchantments, you would do (n-1)*I for each enchantment, along with the base cost of each enchantment

To find the total cost of combining two items, you use:

L=LF+Ik

Where:
 * L is the total level from the anvil process
 * LF is the level cost of the first item (from above)
 * I is the increment value

Once again, when there is a subscript k, you must add on the value for each enchantment.

Looking at the example above:

For the first slot, a sword with sharpness 3, knockback 2 and looting 2.

For the sharpness: The base cost is 1, the level is 3 and the increment is 1. For the knockback: The base cost is 2, the level is 2 and the increment is 2. For the looting: The base cost is 4, the level is 2 and the increment is 4. There are 3 enchantments total, which means E=6 This sword has not been through the anvil process at all, so A=0

This means:

LF=1+(3-1)*1+2+(2-1)*2+4+(2-1)*4+6+2*0

So, our value of LF becomes:

LF=1+2*1+2+1*2+4+1*4+6+0=21 levels

Which is the same as what we found before

To add on a sword that has sharpness 3 and looting 2, we look at the second slot values. Since neither sharpness or looting are at their maximum levels, we do not need to halve the second slot value. For sharpness, the value to add is 2 levels, while for looting, it is 8

This makes:

L=21+2+8=31 levels

This gives the same values as found before

铁砧机制