Minecraft Wiki
m (→‎Video: formatted note)
(→‎Bookshelf placement: "lower than maximum level" doesn't much matter in 1.8, but if seeking a rare enchantment being able to try any level is very helpful. So add info on that.)
Line 214: Line 214:
 
}}
 
}}
   
  +
=== Selecting an enchantment level ===
An easy way to limit the maximum level of enchantment offered is to disable bookshelves by placing torches between them and the enchantment table. That way one can still have the entire 'ring' of bookshelves around the table, but get lower-level enchantments when desired. Breaking the torches will restore the effect of the bookshelves.
 
   
For the bookshelves to operate, the 2-high area between the enchanting table and the bookshelves must be completely clear. In addition to torches, objects like snow or [[carpet]] will disable the effect of bookshelves.
+
As enchantments offered depend on the enchantment level and the enchantment level depends on the number of active bookshelves, an easy way to change the enchantments offered is to disable bookshelves by placing torches between them and the enchantment table. That way one can still have the entire 'ring' of bookshelves around the table but get lower-level enchantments. Breaking the torches will restore the effect of the bookshelves.
  +
  +
[[File:Enchantment table bookshelf placement.png|thumb|right]]
  +
With the layout shown here, enchantments with any number of bookshelves from 1–15 may be easily checked:
  +
{| class="wikitable mw-collapsible mw-collapsed" style="text-align:center"
  +
! {{BlockSprite|wool}} !! {{BlockSprite|wool-red}} !! {{BlockSprite|wool-blue}} !! {{BlockSprite|wool-black}} !! Active bookshelves
  +
|-
  +
| {{BlockSprite|torch}} || {{BlockSprite|torch}} || {{BlockSprite|torch}} || {{BlockSprite|torch}} || 0
  +
|-
  +
| {{BlockSprite|air}} || {{BlockSprite|torch}} || {{BlockSprite|torch}} || {{BlockSprite|torch}} || 1
  +
|-
  +
| {{BlockSprite|torch}} || {{BlockSprite|air}} || {{BlockSprite|torch}} || {{BlockSprite|torch}} || 2
  +
|-
  +
| {{BlockSprite|air}} || {{BlockSprite|air}} || {{BlockSprite|torch}} || {{BlockSprite|torch}} || 3
  +
|-
  +
| {{BlockSprite|torch}} || {{BlockSprite|torch}} || {{BlockSprite|air}} || {{BlockSprite|torch}} || 4
  +
|-
  +
| {{BlockSprite|air}} || {{BlockSprite|torch}} || {{BlockSprite|air}} || {{BlockSprite|torch}} || 5
  +
|-
  +
| {{BlockSprite|torch}} || {{BlockSprite|air}} || {{BlockSprite|air}} || {{BlockSprite|torch}} || 6
  +
|-
  +
| {{BlockSprite|air}} || {{BlockSprite|air}} || {{BlockSprite|air}} || {{BlockSprite|torch}} || 7
  +
|-
  +
| {{BlockSprite|torch}} || {{BlockSprite|torch}} || {{BlockSprite|torch}} || {{BlockSprite|air}} || 8
  +
|-
  +
| {{BlockSprite|air}} || {{BlockSprite|torch}} || {{BlockSprite|torch}} || {{BlockSprite|air}} || 9
  +
|-
  +
| {{BlockSprite|torch}} || {{BlockSprite|air}} || {{BlockSprite|torch}} || {{BlockSprite|air}} || 10
  +
|-
  +
| {{BlockSprite|air}} || {{BlockSprite|air}} || {{BlockSprite|torch}} || {{BlockSprite|air}} || 11
  +
|-
  +
| {{BlockSprite|torch}} || {{BlockSprite|torch}} || {{BlockSprite|air}} || {{BlockSprite|air}} || 12
  +
|-
  +
| {{BlockSprite|air}} || {{BlockSprite|torch}} || {{BlockSprite|air}} || {{BlockSprite|air}} || 13
  +
|-
  +
| {{BlockSprite|torch}} || {{BlockSprite|air}} || {{BlockSprite|air}} || {{BlockSprite|air}} || 14
  +
|-
  +
| {{BlockSprite|air}} || {{BlockSprite|air}} || {{BlockSprite|air}} || {{BlockSprite|air}} || 15
  +
|}
   
 
==How Enchantments Are Chosen==
 
==How Enchantments Are Chosen==

Revision as of 11:37, 17 September 2014

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 15) and which slot position it is in.

Base enchantment level available (base) = (1..8 + floor(b/2) + 0..b),

where b is the number of nearby bookshelves (maximum of 15) and x..y generates a uniformly distributed random integer between x and y inclusive. This is then modified according to the slot position:

Top slot enchantment level = max (base / 3, 1)
Middle slot enchantment level = (base × 2) / 3 + 1
Bottom slot enchantment level = max (base, b × 2)

Prior to version 1.3, the enchantment level available was (1..5 + floor(b/2) + 0..b), multiplied by a 'slot factor' of 13, 23, or 1 for the top, middle, and bottom slots respectively. The lowest level available was equal to half the number of bookshelves used.

Prior to version 1.1, the floor(b/2) term in the above equation was 0..floor(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.

Number of Bookshelves 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Min Level (in top slot) 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2
Max Level (in bottom slot) 8 9 11 12 14 15 17 18 20 21 23 24 26 27 29 30
Number of Bookshelves 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Level range of top slot 1 - 2 1 - 3 1 - 3 1 - 4 1 - 4 1 - 5 1 - 5 1 - 6 1 - 6 1 - 7 2 - 7 2 - 8 2 - 8 2 - 9 2 - 9 2 - 10
Level range of middle slot 1 - 6 1 - 7 2 - 8 2 - 9 3 - 10 3 - 11 3 - 12 3 - 13 4 - 14 4 - 15 5 - 16 5 - 17 5 - 18 5 - 19 6 - 20 6 - 21
Level range of bottom slot 1 - 8 2 - 9 4 - 11 6 - 12 8 - 14 10 - 15 12 - 17 14 - 18 16 - 20 18 - 21 20 - 23 22 - 24 24 - 26 26 - 27 28 - 29 30 - 30

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

Bookshelf placement

Nearby bookshelves raise the available enchantment levels; without any bookshelves the experience level cost will never exceed 8.

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 2-high space between the bookshelf and table must be Air (even a torch, snow cover or carpet 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

Note that the glyph particles which fly from bookshelves follow different rules and may appear even if the bookshelves are not enhancing the table.

There are many possible bookshelf arrangements that can reach the enchantment limit. A simple method is to surround the enchantment table with a 1-block high square of bookshelves with an empty space anywhere on the perimeter:

Another alternative that is now available is to build a 'library corner' where each bookshelf is two blocks high, as in the plan below. This arrangement gives space for 16 shelves, which is one more than needed.

Selecting an enchantment level

As enchantments offered depend on the enchantment level and the enchantment level depends on the number of active bookshelves, an easy way to change the enchantments offered is to disable bookshelves by placing torches between them and the enchantment table. That way one can still have the entire 'ring' of bookshelves around the table but get lower-level enchantments. Breaking the torches will restore the effect of the bookshelves.

Enchantment table bookshelf placement

With the layout shown here, enchantments with any number of bookshelves from 1–15 may be easily checked:

Active bookshelves
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

How Enchantments Are Chosen

"Enchantment level" is the cost of the enchantment in experience levels (the green number on the bottom). "Enchantment power" is the strength of the particular enchantment. For example, "Sharpness IV" has a power of 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 half the enchantability, then adds that number plus one to the enchantment level. Bows and books 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 a quarter of the enchantability are much more likely than results at the extremes.

modified enchantment level = base enchantment level + Random(0, enchantability / 4) + Random(0, enchantability / 4) + 1
(Rounding Down after each step)
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.85 and 1.15, again with a triangular distribution. The modified enchantment level is multiplied by this value (so it could increase or decrease by up to 15%) and then rounded down to the nearest integer.

Step 1 pseudocode

// Returns a uniformly distributed random integer between 0 and n - 1, inclusive
function randomInt(n);

// returns a uniformly distributed random real (fractional) number between 0 (inclusive) and 1 (exclusive)
function randomFloat();


// Generate a random number between 1 and 1+(enchantability/2), with a triangular distribution
enchantability_2 = enchantability / 2;
int rand_enchantability = 1 + randomInt(enchantability_2 / 2 + 1) + randomInt(enchantability_2 / 2 + 1);

// Choose the enchantment level
int k = chosen_enchantment_level + rand_enchantability;

// A random bonus, between .85 and 1.15
float rand_bonus_percent = 1 + (randomFloat() + randomFloat() - 1) * 0.15;

// Finally, we calculate the level
int final_level = (int)(k * rand_bonus_percent + 0.5);

Source:[1]

Step Two - Find possible enchantments

Powersword

A sword with several enchantments. (In versions 1.3+, Sharpness V is unobtainable on diamond swords unless using the anvil introduced in 1.4.)

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.

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
Feather Fall 5
Fire Protection 5
Projectile Protection 5
Aqua Affinity 2
Blast Protection 2
Respiration 2
Thorns 1
Sword Enchantments Weight
Sharpness 10
Bane of Arthropods 5
Knockback 5
Smite 5
Fire Aspect 2
Looting 2
Tool Enchantments Weight
Efficiency 10
Unbreaking 5
Fortune 2
Silk Touch 1
Bow Enchantments Weight
Power 10
Flame 2
Punch 2
Infinity 1

After the first enchantment is selected, there is a chance of receiving more. Additional enchantments are chosen by 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.

When enchanting books using an enchantment table, if multiple enchantments were generated then one selected at random will be removed from the final list. This does not apply to other sources of enchanted books that use enchantment mechanics, such as fishing or chests in generated structures.

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. Such a website, updated for 1.43 to 1.7, can be found here.

Enchantment Probability Charts

For an interactive enchantment chart head over to beefcraft.net.

Another enchantment probability calculator is at minecraftenchantmentcalculator.com.

A spreadsheet with a chart (File:Enchant Probabilities 1.4.6.zip) that detail the probabilities of different enchantments on 1.4.6 based on one million samples per item type per exp level.

A bunch of charts on the probabilities of different enchantments on 1.3 here. There is a separate set for enchanting prior to 12w22a here.

Video

Note: the video says Endermen are affected by Smite; this is not true.

Enchantment Mechanics/video

References

  1. Minecraft 1.3.2 source code