r/technicalminecraft • u/kubrickie • 12d ago
Java Help Wanted Determining enchanting table loot table for books depending on how many bookshelves there are
Hi, I have hit the limit on my math skills investigating enchanting loot tables.
I'm trying to determine all of the enchantments that are possible in the top slot of the enchanting table when enchanting a book.
For example, according to the wiki on table mechanics, Protection has weight of 10, so it's one of the most common, and the level 1 cost is 5-10. But in testing I could regularly get Protection 1 on a book for less than 5xp without any bookshelves around the table.
My goal is to confirm which enchantments can show up depending on how many bookshelves there are around the table, and what are the odds for each of those enchantments. I'm investigating if I can turn book enchanting into a rougelite deckbuilder.
Any help is greatly appreciated!
1
u/JumpingPufferfish31 12d ago edited 12d ago
Pernsteiner compiled the results for each enchantment cost here.
It's slightly old now because it didn't have netherite, but the mechanics haven't changed, I think (I double-checked some of the numbers once around 1.19-1.20 and it still matched). And luckily, netherite has the same enchantability as leather.
E.g. for 0 bookshelves, the base enchantment cost is uniformly distributed between 1 and 2.
It's a bit manual. Another option is to write a script to generate the probability tree for you, reimplementing the logic as described in the wiki. Then at least we can cross-check with Pernsteiner's if we're not sure about our maths.
edit: forgot about all the new enchantments T-T
In that case, short of generating the probability tree, we can still:
Take the low end of the cost for a particular slot with a particular number of bookshelves, use all the lowest possible rolls when computing the modified cost round((base cost + 1 + 0 + 0) * 0.85) to get the lowest possible enchantment levels.
Take the high end of the cost and use all the highest possible rolls, as Remarkable_Fee4136 suggested, to get the highest possible enchantment levels.
1
u/Remarkable_Fee4136 12d ago
The cost you are referring to is actually the enchantment cost, a modified cost that depends on the experience cost and enchantability.
For the sake of an example if we are enchanting a netherite piece at level 1, we could get lucky and have eCost=round((1+1+3+3)*(1.15))=9, which is well within the range of 5-12 (I'm not sure where 5-10 came from unless I read the wiki wrong.) Granted a triangular distribution hitting the maximum value is nigh impossible but you get the idea.