- 1 Min/Max Levels
- 2 probability after 1.3.1
- 3 Move page
- 4 How about books?
- 5 Slot
- 6 Enchant Probability Update
- 7 Step 3 explanation
- 8 Step 1: Code or Text?
- 9 Possible Mistake for 14 bookselves
- 10 Clarification for modified enchantment leve
- 11 Fishing rod
- 12 Enchantment probabilities w/preview
- 13 Cursed Enchantments
- 14 Sweeping Edge
- 15 Latest update using 32767 in place of 1 and 2
According to the page, the min and max range for bookshelves, b, seems a bit weird to me when b = 30. Even if that table is designed using the third slot, the formula itself gives me a minimum level of 16 to 50. If it was designed for the first slot, which sets s to 0.5, i get a range of 8 to 25 not the min of 9 shown there. On the off-hand chance of it being designed for the second slot, it gets a range for 11 to 33. Where is it that it's getting a minimum level of 9? Kalbintion 22:06, 7 June 2012 (UTC)
- The maximum assumes the bottom slot is used, and the minimum uses the top slot. The problem is that the formula is not quite accurately described. Starting with
Base enchantment level available = (1..5 + (b/2) + 0..b)
- where b is the number of bookshelves (as on the page currently), the top slot has
Actual level = (base / 2) + 1
- and the middle slot has
Actual level = ((base * 2) / 3) + 1
- All calculations are performed in integer arithmetic (all fractions round down). That '+ 1' is why the minimum level with 30 bookshelves is 9, rather than 8. Of course, all this may have changed in the latest snapshot releases. -- Orthotope 01:36, 8 June 2012 (UTC)
- The base formula still seems wrong. With 15 bookshelves, you get a base of 1..5 + (15/2) + 0..15, thus the max level available would be 5 + 7 + 15 = 27 (and 5 with no bookshelves at all). Ord did I get something wrong ? --22.214.171.124 08:32, 2 September 2012 (UTC)
- I got exactly the same answer in as the previous post using the formula as it is on the page. I also used the formula to calculate the minimum for b = 15. That gives me exactly 4.25, while this page says it should be 2 (rounded down). I also got the same answer for b = 0, so I think somethings wrong with this formula. --Creator13 18:40, 17 September 2012 (UTC)
- This was changed in 1.3. New formulas:
Base level = (1..8 + (b/2) + 0..b) Top slot level = max(base / 3, 1) Middle slot level = ((base * 2) / 3) + 1 (same as before) Bottom slot level = max(base, b * 2)
- -- Orthotope 02:18, 18 September 2012 (UTC)
- Sorry for complaining more, but I don't understand some parts of the formula, like the "max" before the top and bottom slot formula; and in the top slot, I don't understand the comma between the 3 and the 1. Does this mean 3.1, or anything else of a higher mathematical level than I have :/ ? Please forgive me about asking this, but I'm writing a program where I need these formulas. By the way, may we ask things like this on the discussion page, if not, please tell me so I know it for the next time... --Creator13 19:48, 18 September 2012 (UTC)
max(a, b)picks the greater of the two numbers a and b. In the top slot, this ensures the level is at least 1 (with no bookshelves, base can be as low as 1, and in integer arithmetic 1/3 = 0). In the bottom slot, the level will always be at least twice the number of bookshelves. This is why it always gives a level 30 enchantment when you have 15 bookshelves nearby. -- Orthotope 03:02, 19 September 2012 (UTC)
- Thanks, really, this helped me alot. Except that I now have to rewrite the code... Creator13 19:00, 19 September 2012 (UTC)
probability after 1.3.1
Can anyone confirm these probability charts? According to the charts it is no longer possible to get efficiency 5 on a diamond pick.
- Also not possible to get Sharpness V on diamond sword and it's only 0.2% chance on a golden sword with level 30. 126.96.36.199 23:58, 19 August 2012 (UTC)
- They originally were on the same page. This information was split off as it's rather technical, and players don't need to understand it in order to make use of enchantments. -- Orthotope 08:52, 7 December 2012 (UTC)
- Actually it isn't technical, but not everyone can figure out the ideal enchantment level using math.188.8.131.52 21:16, 22 February 2015 (UTC)
How about books?
Enchantability is clearly not an issue, but contra some rumors, I did see enchantments up to level 30 when I tried it (only once so far). Can anyone figure out how enchanted books pick their results? --Mental Mouse 21:32, 21 December 2012 (UTC)
- I only did some experimenting in creative, but I noticed that books will only pick one enchantment. You can use up to 30 levels to enchant them, and the higher the level, the more likely for a higher level/better enchantment. I would assume that the algorithm is very much the same, only it picks 1 enchantment rather than allowing for multiples. I'd be interested to see what other people find as well. --Kahless61 21:37, 21 December 2012 (UTC)
- I added a spreadsheet to the Enchant Probabilities Chart section at the bottom of the article. It includes the probabilities for enchantments on books. It's in an old Excel format, which I hope is acceptable. Teh chad 18:41, 8 January 2013 (UTC)
- Perhapse you could decrypt the excel format with reguard to Silk Touch on a book. Being that the only legitimate method of obtaining webs is to aquire a silk touch book to enchant shears, discovering the most effective number of levels to apply has become a noteworthy challenge. [[Pestilencemage]] 1 Febuary 2013
Please, explain what is meaning of word "slot" in this text. In the text of Enchantment_Table is used word "slot" for square to place an item. On the right side of slot there are 3 buttons for displaying cryptic runes. Is the "slot" meaning the "button" in the text of Enchantment_mechanics? Thanks. –Preceding unsigned comment was added by Bj9 (Talk|Contribs) 17:48, 4 January 2013 (UTC). Please sign your posts with ~~~~
- Yes, they are using the word "slot" to mean the three buttons on the right side of the enchant display. They probably could have chosen a more specific word. Teh chad 18:38, 8 January 2013 (UTC)
Enchant Probability Update
I created a test harness to test enchantment probabilities. It takes a list of all enchantable items and loops through all 30 possible levels spent on each enchantment. It does one million enchantments per item per experience level. This means that there are 30 million tests done per item type. I added a link to the spreadsheet at the bottom of the main article in the Enchantment Probability Chart section. The spreadsheet is in an older Excel format, so it should be able to be opened by open source spreadsheet programs. I included the aggregated raw data in the spreadsheet as well. It should provide a pretty interesting read. --Teh chad 17:47, 8 January 2013 (UTC)
Step 3 explanation
I think there is too little information in step 3. It's about selecting the enchantments which will be applied to the item, but I don't actually see anything on how that actually happens. Also, I don't get the formula: what is "P(enchantment)"? Could anyone please help me with this? I need it for for a program I'm making, so... --Creator13 19:15, 21 March 2013 (UTC)
- In plain english, that formula says the probability of any given enchantment being chosen is the weight of that enchantment divided by the sum of the weights of all possible enchantments for the item being enchanted. In code, this is usually done by generating a random integer less than that sum, and figuring out which weighted enchantment it corresponds to. For example, the tool enchantments have weights of 10, 1, 5, and 2, so you'd generate a random number in the range 0-17 inclusive: 0-9 would be Efficiency, 10 is Silk Touch, 11-15 for Unbreaking, and 16-17 is Fortune. Make sense? -- Orthotope 04:26, 22 March 2013 (UTC)
- Wouldn't it be an idea to post this on the main page? 184.108.40.206 17:25, 22 March 2013 (UTC)
Step 1: Code or Text?
It seems to be some inconsistency between the textual description and some of the formulas / pseudocode:
"Minecraft picks a number between 0 and half the enchantability, (actually 1/4 rounded down and multiplied by 2)"
"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"
If the random number is between 0 and half enchantability, then results of a triangular distribution should be close to a quarter of enchantability, not half.
But then, pseudocode presents this:
int rand_enchantability = 1 + randomInt(enchantability_2 / 2 + 1) + randomInt(enchantability_2 / 2 + 1);
Which seems to be a triangular distribution between 0 and full enchantability (not half), which does make half enchantability results more likely.
So, what is the correct behavior? MestreLion 05:06, 5 July 2013 (UTC)
- Note the previous line in the pseudocode:
enchantability_2 = enchantability / 2. I changed the text to be a bit less confusing. -- Orthotope talk 06:37, 5 July 2013 (UTC)
Possible Mistake for 14 bookselves
Given the formula
(base) = (1..8 + floor(b/2) + 0..b)
Bottom slot enchantment level = max (base, b × 2)
When b = 14 (14 bookcases), and assuming highest random number you get:
(base) = 8 + floor(14/7) + 14 = 29
b × 2 = 28
max (29, 28) = 29
However, it is recorded that the highest level for 14 bookshelves is 28.
0pteron 17:43, 15 August 2013 (UTC)
Update desperately needed!
This page desperately needs to be updated to include the new enchants added in 1.6. (Fishing.) We now have 1.7 and they still haven't been added! 220.127.116.11 14:44, 21 February 2014 (UTC)
- There should be information for the enchantability of a fishing rod.
18.104.22.168 04:34, 29 January 2015 (UTC)
Clarification for modified enchantment leve
The article says that the level is multiplied by a random value from 0.85 to 1.15. How is this rounded?22.214.171.124 03:32, 28 January 2015 (UTC)
Quote from the article: "The modified enchantment level is multiplied by this value (so it could increase or decrease by up to 15%) and then rounded to the nearest integer." –KnightMiner (t·c) 03:53, 28 January 2015 (UTC)
This page does not have the enchantability of a fishing rod. What is the enchantability of a fishing rod?126.96.36.199 21:13, 22 February 2015 (UTC)
Enchantment probabilities w/preview
I don't see it anywhere, but it would certainly be nice to have a chart for the probabilities of getting an enchantment level with the a priori knowledge of getting the enchantment class. For instance, at level 30, you have an 8.6% chance of getting Fortune III, and a 5.3% chance of getting Fortune II. But, from the preview I already know I'm getting Fortune X so in reality my chance of getting Fortune III is: 8.6 / (8.6 + 5.3) = 62% chance. At least on the console version, it only seems to show the enchantment from base level (30 < 33, so Fortune II) in the preview and the actual enchantment uses the full formula. 188.8.131.52 17:01, 31 March 2016 (UTC)
I was hoping to update the table under the "Step Three" section with the new cursed enchantments, but am unaware of their weights. Does anyone know what they are, or how to find out? Thanks. DelboyDylan (talk) 18:07, 10 October 2016 (UTC)
- They're both weight 1. If you can see into a decompiled 16w40a jar, in the aie.class, you can see at the bottom where it's registering all the enchantments, where the parameter is
new aia( aia.a.d, ..., that it's using the same value for the curses as it does for Thorns, Silk Touch and Infinity. – Sealbudsman talk/contr 20:30, 10 October 2016 (UTC)
- Someone would need to check the code to find out. Orthotope? Anomie x? 16:07, 10 January 2017 (UTC)
- It's not a treasure enchantment.
- In the decompiled 1.11.2.jar,
aiv.classcorresponds to the Sweeping enchantment, and it does not override the default behavior of the Enchantment abstract class
aii.class, which is that
c()(a.k.a. in MCP 9.31
isTreasureEnchantment()) returns false. This is the method that returns true in the case of Frost Walker, Mending and both Curses.
- Also for future reference, you can sort of tell that it's not a treasure enchantment: a treasure enchantment is one that "can never be created by an enchantment table," (see the paragraph at treasure enchantment) whereas Sweeping can be applied to swords on an enchantment table (see the entry at Sweeping Edge). But on the other hand, it never hurts to check! – Sealbudsman talk/contr 17:17, 10 January 2017 (UTC)
Latest update using 32767 in place of 1 and 2
the anon user that last updated the page changed the algorithm section to use 32757 to N-32767 in place of 0 to 1, but in the second paragraph seems to make a mistake by saying the range is from "32767 to 32767" .. so a range of 1 integer value, which cannot be correct. --Giftig (talk) 20:54, 6 February 2019 (UTC)
and again here --- // A random bonus, between .85 and 1.15 float rand_bonus_percent = 32767 + (randomFloat() + randomFloat() - 32767) * 0.15; --- do you mean to use two different random values, because that is what you get calling randomFloat twice.
The usual fix is to use a temp value float randFloat = randomFloat(); float rand_bonus_percent = 32767 + ( randFloat + randFloat - 32767) * 0.15;
- Feel free to correct anything you find that's incorrect, or to revert it if you don't know how to correct it. You'll find that editors who've been here a long time don't watch tutorials very closely (if at all) because we don't think they even belong on the wiki (they're mostly opinions and suggestions, not factual documentation). Most tutorials are only here because some people put up a big fuss when we tried to delete them. But the creators usually don't keep them up to date, so factual errors are common in them. Caveat lector. – Auldrick (talk · contribs) 21:23, 6 February 2019 (UTC)
- The 32767s are definitely not right and honestly look to me like recent vandalism. I undid those changes.
- By the way, calling
Random.nextFloattwice is correct; source diving reveals that the game does exactly that. This is how it gets a triangular distribution; it's the same as rolling two dice and adding the results. There is also often reason to convert floating-point numbers to integers as is done here, but it's true that it gets messed up sometimes. For instance, in C#, naively doing
(int) (10 * 0.7f)may give 6, which (among other reasons) means the mining outfit in Terraria can boost mining speed by significantly more than it's supposed to.
- The source code in fact uses
Math.Round, instead of the cast used in the pseudocode... I feel it would be clearer and more correct to use
Math.Roundin the pseudocode as well. - Andrio Celos (talk) 04:15, 7 February 2019 (UTC)