The much anticipated 1.3 update for Minecraft is coming out soon, and along with a whole host of new additions to the game, it also brings an overhaul to the enchanting system. This, of course, completely changes the optimum enchanting level-bookshelf relations that I derived for the previous enchanting system, just like the 1.1 update broke the one before that.

I've been digging in the source for the 12w26a snapshot in order to find out what the changes are. To my knowledge, the calculations have not changed since the rebalancing introduced in the 12w22a snapshot released at the end of May. Comparing these to the snippets of source code I had saved from 1.1, I have worked out how the new enchanting levels are calculated.

But, before I get into that, let me once again reiterate why you'd want to understand the enchanting level-bookshelf relation. There are simulators which can calculate the probability of getting a certain enchantment at a certain level (there is an excellent calculator here). This means that if you are looking for a specific enchantment or combination of enchantments, there is an optimum level that would maximise you chances of getting the combination of enchantments that you want. Of course, you can keep rolling new levels to find the level you want, but it is quicker to set the number of bookshelves so that the level you want is most likely to show up, especially if you tend to enchant at the same level every time.

Lets start by looking at the relevant changes as stated in the version history on the wiki:

First, before we get into source code, let's try some in-game testing. The first point is definitely true. Level 30 is indeed the maximum level, and there is no difference in the distribution of levels with more than 15 bookshelves. Now testing the second point. With no bookshelves, it seems we are offered random levels in the bottom slot between 1 and 8. The first obvious difference is that maximum with no bookshelves has been upped from 5. Also it seems you are not always shown the highest number possible. In fact, with 5 bookshelves, you are offered levels between 10 and 15 in the bottom slot, and although 10 bookshelves usually offers level 20, it occasionally offers as high as level 23 in the bottom slot (as in the screenshot below). With 15 bookshelves, however, you always seem to be offered level 30 in the bottom slot. The second point, it seems, is indeed only true for a "

So, what's actually happening in the source code? There are actually only 4 small changes in functionality between 1.1 and 12w26a. The relevant snippets of code (edited slightly to make them more readable) are:

- In version 1.1:

if (nBookShelves > 30) { nBookShelves = 30; }

int level = random.nextInt(5) + 1 + (nBookShelves / 2) +

random.nextInt(nBookShelves + 1);

if (slotNum == 0) { return (level/2) + 1; }

if (slotNum == 1) { return (level*2)/3 + 1; }

else { return level; }

- and in snapshotn 12w26a:

if (nBookShelves > 15) { nBookShelves = 15; }

int level = random.nextInt(8) + 1 + (nBookShelves /2) +

random.nextInt(nBookShelves + 1);

if (slotNum == 0) { return max(level/3, 1); }

if (slotNum == 1) { return (level*2)/3 + 1; }

else { return max(level, nBookShelves*2); }

The changes are:

It is a fairly simple matter to use this to validate the upper and lower bounds for the enchantment levels that we find in-game. The table below shows what these upper and lower bounds are for each number of bookshelves.

For the previous system, I plotted the distributions of levels offered in the bottom slot, but the bottom slot is now heavily skewed toward offering a level equal to twice the number of bookshelves. For instance, with 14 bookshelves, you will be offered a level 28 enchantment 99.2% of the time, with a level 29 enchantment only showing up an average of once every 120 tries. This makes odd levelled enchantments exceptionally difficult to obtain (although none is rarer than the level 50 enchantment was in the 1.1. enchanting system). It also makes a distribution graph look pretty stupid. Even so, I plotted it. Don't ask me why.

The optimum number of bookshelves to use to obtain a specific enchantment level is easy to calculate and is shown in the table below, together with the probability that that enchantment will be offered at that level.

Due to the rarity of high odd numbered levels, it is probably quicker for players to restrict themselves to the even number that gives the best probability for the combination of enchantments they want, rather than use an odd number with a slightly higher probability. As a rule of thumb, for even numbers, take half of the level you want, and use that many bookshelves. It's much easier than it was before.

[Source: minecraft.jar for versions 1.1 and snapshot 12w26a, decompiled with MCP 5.6 and MCP 6.15 respectively.]

I've been digging in the source for the 12w26a snapshot in order to find out what the changes are. To my knowledge, the calculations have not changed since the rebalancing introduced in the 12w22a snapshot released at the end of May. Comparing these to the snippets of source code I had saved from 1.1, I have worked out how the new enchanting levels are calculated.

But, before I get into that, let me once again reiterate why you'd want to understand the enchanting level-bookshelf relation. There are simulators which can calculate the probability of getting a certain enchantment at a certain level (there is an excellent calculator here). This means that if you are looking for a specific enchantment or combination of enchantments, there is an optimum level that would maximise you chances of getting the combination of enchantments that you want. Of course, you can keep rolling new levels to find the level you want, but it is quicker to set the number of bookshelves so that the level you want is most likely to show up, especially if you tend to enchant at the same level every time.

Lets start by looking at the relevant changes as stated in the version history on the wiki:

- "The maximum enchantment level has been lowered from 50 to 30. As a result enchantment tables now require only 15 bookcases around them to allow maximum level enchantments."
- "With a full enchantment table set with bookshelves, at the bottom of the 3 enchantments, it always shows you the highest number possible"

First, before we get into source code, let's try some in-game testing. The first point is definitely true. Level 30 is indeed the maximum level, and there is no difference in the distribution of levels with more than 15 bookshelves. Now testing the second point. With no bookshelves, it seems we are offered random levels in the bottom slot between 1 and 8. The first obvious difference is that maximum with no bookshelves has been upped from 5. Also it seems you are not always shown the highest number possible. In fact, with 5 bookshelves, you are offered levels between 10 and 15 in the bottom slot, and although 10 bookshelves usually offers level 20, it occasionally offers as high as level 23 in the bottom slot (as in the screenshot below). With 15 bookshelves, however, you always seem to be offered level 30 in the bottom slot. The second point, it seems, is indeed only true for a "

*full*enchantment table set".**Figure 1**: Screenshot showing enchantment level 23 being offered with 10 bookshelves (which happens about 1.13% of the time)

So, what's actually happening in the source code? There are actually only 4 small changes in functionality between 1.1 and 12w26a. The relevant snippets of code (edited slightly to make them more readable) are:

- In version 1.1:

if (nBookShelves > 30) { nBookShelves = 30; }

int level = random.nextInt(5) + 1 + (nBookShelves / 2) +

random.nextInt(nBookShelves + 1);

if (slotNum == 0) { return (level/2) + 1; }

if (slotNum == 1) { return (level*2)/3 + 1; }

else { return level; }

- and in snapshotn 12w26a:

if (nBookShelves > 15) { nBookShelves = 15; }

int level = random.nextInt(8) + 1 + (nBookShelves /2) +

random.nextInt(nBookShelves + 1);

if (slotNum == 0) { return max(level/3, 1); }

if (slotNum == 1) { return (level*2)/3 + 1; }

else { return max(level, nBookShelves*2); }

The changes are:

- The number of bookshelves is capped at 15, rather than 30.
- The random modifier for the level is between 1 and 8, rather than 1 and 5.
- The top slot shows one third of the calculated level, rather than one half.
- The level offered in the bottom slot now has a lower bound equal to twice the number of bookshelves.

It is a fairly simple matter to use this to validate the upper and lower bounds for the enchantment levels that we find in-game. The table below shows what these upper and lower bounds are for each number of bookshelves.

Shelves | Top | Middle | Bottom |

0 | 1-2 | 1-6 | 1-8 |

1 | 1-3 | 1-7 | 2-9 |

2 | 1-3 | 2-8 | 4-11 |

3 | 1-4 | 2-9 | 6-12 |

4 | 1-4 | 3-10 | 8-14 |

5 | 1-5 | 3-11 | 10-15 |

6 | 1-5 | 3-12 | 12-17 |

7 | 1-6 | 3-13 | 14-18 |

8 | 1-6 | 4-14 | 16-20 |

9 | 1-7 | 4-15 | 18-21 |

10 | 2-7 | 5-16 | 20-23 |

11 | 2-8 | 5-17 | 22-24 |

12 | 2-8 | 5-18 | 24-26 |

13 | 2-9 | 5-19 | 26-27 |

14 | 2-9 | 6-20 | 28-29 |

15 | 2-10 | 6-21 | 30 |

For the previous system, I plotted the distributions of levels offered in the bottom slot, but the bottom slot is now heavily skewed toward offering a level equal to twice the number of bookshelves. For instance, with 14 bookshelves, you will be offered a level 28 enchantment 99.2% of the time, with a level 29 enchantment only showing up an average of once every 120 tries. This makes odd levelled enchantments exceptionally difficult to obtain (although none is rarer than the level 50 enchantment was in the 1.1. enchanting system). It also makes a distribution graph look pretty stupid. Even so, I plotted it. Don't ask me why.

The optimum number of bookshelves to use to obtain a specific enchantment level is easy to calculate and is shown in the table below, together with the probability that that enchantment will be offered at that level.

Level | Shelves | Probability |

1 | 0 | 71.3% |

2 | 1 | 55.6% |

3 | 2 | 40.6% |

4 | 2 | 34.4% |

5 | 2 | 34.4% |

6 | 3 | 50.8% |

7 | 3 | 31.6% |

8 | 4 | 55.0% |

9 | 4 | 23.4% |

10 | 5 | 70.1% |

11 | 10 | 18.2% |

12 | 6 | 73.7% |

13 | 12 | 15.4% |

14 | 7 | 84.4% |

15 | 14 | 13.3% |

16 | 8 | 86.1% |

17 | 15 | 10.2% |

18 | 9 | 92.5% |

19 | 15 | 5.5% |

20 | 10 | 93.2% |

21 | 10 | 3.4% |

22 | 11 | 96.9% |

23 | 11 | 2.1% |

24 | 12 | 97.1% |

25 | 12 | 1.9% |

26 | 13 | 99.1% |

27 | 13 | 0.9% |

28 | 14 | 99.2% |

29 | 14 | 0.8% |

30 | 15 | 100.0% |

Due to the rarity of high odd numbered levels, it is probably quicker for players to restrict themselves to the even number that gives the best probability for the combination of enchantments they want, rather than use an odd number with a slightly higher probability. As a rule of thumb, for even numbers, take half of the level you want, and use that many bookshelves. It's much easier than it was before.

[Source: minecraft.jar for versions 1.1 and snapshot 12w26a, decompiled with MCP 5.6 and MCP 6.15 respectively.]

*If you enjoyed this post, then don't forget to like, tweet, +1, or upvote on reddit. If you have any questions, comments or complaints, post them using the form below.*

. . . . . . . . . . . . . . . . . . . . . . . .