Minecraft Wiki
Advertisement

This article is about the mechanics of Enchanting.


Basic Mechanics

Whenever you place an eligible item on the Enchantment Table, the enchantment levels available are randomly generated for each slot using the formula below. The enchantment level is dependent upon the number of nearby bookshelves (capped at 30) and a "slot factor" of 0.50 for the topmost enchantment slot, 0.66 for the middle slot, and 1.00 for the bottom slot. (If the number of bookshelves is 0, the second two random integers will always be zero. When placing bookshelves around the Enchanting Table they CANNOT be touching the table or the table will not change from 5.)

Enchantment level available = (1..5 + (b/2) + 0..b) × s,

where b is the number of nearby bookshelves (maximum of 30), s is the slot factor for the given enchantment slot, and x..y generates a uniformly distributed random integer between x and y inclusive. The lowest level available is equal to half the number of book shelves used.

Prior to version 1.1, the (b/2) term in the above equation was 0..(b/2), resulting in more randomness, and making the search for high level enchantments an extremely time consuming process. Prior to 1.1, the lowest level available was 1, regardless of the number of bookshelves used.

Bookshelves 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Min Level 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9
Max Level 5 6 8 9 11 12 14 15 17 18 20 21 23 24 26 27 29 30 32 33 35 36 38 39 41 42 44 45 47 48 50

In Creative mode, no levels or experience are necessary for enchantments.

Bookshelf placement

Nearby bookshelves raise the available enchantment levels. As of Beta 1.9 Pre-release 4, no enchantments costing above five Experience levels are available unless you place bookshelves near but not touching the Enchantment Table. In order to have an effect, a bookshelf must be placed exactly 2 blocks, laterally, off the enchantment table and be on the same level or one block height above the table, and the space between the bookshelf and table must be Air (even a torch or snow cover will block the effect), where “between” is as shown in the following diagrams (the white spaces are air, and the do not matter):

Like this from the top:
or
and like this from the side:
or

An enchantment table can be surrounded by 30 bookshelves by placing them in a square around the table, with each wall measuring 5 blocks wide and 2 blocks high, with a 2 block high doorway. This arrangement gives the maximum possible boost.[1] (While it is possible to get two more bookshelves in "range", they do not add, as the boost is capped.)


An easy way to limit the maximum level of enchantment available, if you want to do a lower-level enchantment, is to put torches on the bookshelves so that they aren't recognized by the enchantment table. That way you can still have the entire 'ring' of bookshelves around the table, but get lower-level enchantments when you need them. Breaking the torches will restore the maximum level to its original amount.

An important thing to remember is to keep the area between the enchanting table and the bookshelves completely clear. Things like snow can cancel out the effect of all the bookshelves, and will render them useless until the snow is cleared. A safe bet is to completely clear the workspace unless you are intentionally doing so to obtain lower level enchantments.


How Enchantments Are Chosen

"Enchantment level" is the cost of the enchantment in experience levels (the green number on the button). "Enchantment power" is the strength of the particular enchantment. For example, "Sharpness IV" has power 4. The enchantment algorithm uses a three-step process.

Step One - Applying modifiers to the enchantment level

The first thing that Minecraft does is apply two modifiers to the base enchantment level. Each modifier is restricted to a certain range, with numbers close to the middle of the range more common than those near the ends.

The first modifier is based on the item's "enchantability," which depends on the material and the type of the item (see the table below). Minecraft picks a number between 0 and the enchantability, then adds that number plus one to the enchantment level. Bows have an enchantability of 1 for this purpose. This random value follows a triangular distribution (like rolling a pair of dice and adding) so results close to half the enchantability are much more likely than results at the extremes.

modified enchantment level = enchantment level + Random(0, enchantability) + 1
Material Armor enchantability Sword/Tool enchantability
Wood N/A 15
Leather 15 N/A
Stone N/A 5
Iron 9 14
Chain 12 N/A
Diamond 10 10
Gold 25 22

Next, Minecraft picks a value between 0.75 and 1.25, again with a triangular distribution. The modified enchantment level is multiplied by this value (so it could increase or decrease by up to 25%) and then rounded to the nearest integer.

Step 1 pseudocode

/* Returns a uniformly distributed random number between [0,n) */
function randomInt(n);

/* returns a uniformly distributed random number between [0,1) */
function randomFloat();

int j = item_enchantability
int i = chosen_enchantment_level
int j2 = 1 + randomInt(j/2 + 1) + randomInt(j/2 + 1);
int k = j2 + i;
float f = (randomFloat() + randomFloat() - 1) * 0.25;
int final_level = (int)((float)k * (1.0 + f) + 0.5);

Source:[2]

Step Two - Find possible enchantments

Powersword

A sword with several enchantments.

Now, based on the modified level, Minecraft makes a list of all enchantment types that can be applied to the target item along with the power that each enchantment will have.

The power of each enchantment type is determined by the level and the values in the enchantments levels table. For each power value of an enchantment type, there is a minimum and maximum modified level that can produce the enchantment at that power. If the modified enchantment level is within the range, then the enchantment will be assigned that power. If the modified level is within two overlapping ranges for the same enchantment type, the higher power value is used. The Enchantview mod will help you see what enchantments you will get.


File:Enchanting levels.png

A chart showing all possible enchantments' relationship with modified levels.

Step Three - Select a set of enchantments from the list

Now that it has a list of the possible enchantments for the item, Minecraft must pick some of them that will actually be applied.

You always get at least one enchantment. The first enchantment is picked from a list of statistical "weights" - the enchantment with the higher weight has a higher chance of being selected.

P(enchantment) = (enchantment weight) / ( ∑i=1number of possible enchantments〖enchantment weighti 〗)
Armor Enchantments Weight
Protection 10
Fire Protection 5
Feather Fall 5
Blast Protection 2
Projectile Protection 5
Respiration 2
Aqua Affinity 2
Sword Enchantments Weight
Sharpness 10
Smite 5
Bane of Arthropods 5
Knockback 5
Fire Aspect 2
Looting 2
Tool Enchantments Weight
Efficiency 10
Silk Touch 1
Unbreaking 5
Fortune 2
Bow Enchantments Weight
Power 10
Punch 2
Flame 2
Infinity 1

After the first enchantment is selected, there is a chance of receiving more, based on this algorithm:

  1. Divide the modified level in half, rounded down. (This does not affect the possible enchantments themselves, because they were all pre-calculated in Step Two.)
  2. With probability (modified level + 1) / 50, keep going. Otherwise, stop picking bonus enchantments.
  3. Remove from the list of possible enchantments anything that conflicts with previously-chosen enchantments.
  4. Pick one enchantment from the remaining possible enchantments (based on the weights, as before) and apply it to the item.
  5. Repeat from step 1.

Conflicting Enchantments

Some enchantments conflict with other enchantments and thus both can't be enchanted into the same item, effectively taking down the possibility for one to get an overpowered weapon.

The rules for enchantment conflicts are:

  • Every enchantment conflicts with itself. (So you can't get a tool with two copies of the Efficiency enchantment.)
  • All protection enchantments conflict with each other, so an item can only have one at a time. (In the code, Feather Fall is implemented as a protection enchantment, but it doesn't conflict with the others.)
  • All damage enchantments (Sharpness, Smite, and Bane of Arthropods) conflict with each other.
  • Silk Touch and Fortune also conflict with each other. (The Silk Touch enchantment has no effect on a pickaxe that also has Fortune, such as could be obtained in a 1.9 pre-release or with an inventory editor, since a Silk Touch pickaxe cannot mine resources such as diamonds or coal—only their ore blocks.)


Image005

A chart showing all possible enchantments on diamond tools..

Enchantment Simulator

A website for testing and simulating enchantments can be found here.

Enchantment Probability Charts

A bunch of charts on the probabilities of different enchantments here. There is a separate set for the 12w22a version here.

Video

Enchantment Mechanics/video


References

Advertisement