What amount of bookshelves and experience levels is required for which enchantments?

I am kind of looking for a list of them like for instance how many bookshelves and experience is required for luck of the sea to be available, i know the silk touch enchantment requires 30 levels and 15 bookshelves, can someone give me a list with this kind of data on enchantments?


From Enchantment mechanics on the wiki:

Number of Bookshelves Level range of top slot Level range of middle slot Level range of bottom slot
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

This base enchantment level is modified using 2 modifiers:

  1. A random integer is generated between 0 and half the enchantability of the item (see the table below). This number + 1 is added to the base enchantment level.
Material Armour Enchantability Sword/Tool Enchantability
Wood N/A 15
Leather 15 N/A
Stone N/A 5
Chain 12 N/A
Iron 9 14
Gold 25 22
Diamond 10 10
Turtle 9 N/A
Netherite 15 15
Book 1 1

Bows and fishing rods also have an enchantability of 1

  1. A random number is chosen between 0.85 and 1.15. This is multiplied to the modified level from step 1. This means that the modified level can increase or decrease by up to 15%.

On Enchanting/Levels (permalink) there is a list of the modified enchantment level ranges for each enchantment (excluding crossbows Edit: crossbow enchantments have been added). If the modified enchantment level is in two ranges for the same enchantment type (e.g. Fortune I and Fortune II), the higher one is used.


Edit

i know that the silk touch enchantment requires 30 levels and 15 bookshelves

I assume by "require" you mean that there is a 100% chance that the game may pick an enchantment after the modified enchantment level has been calculated.

For example, to find the number of bookshelves and levels needed to get Silk Touch on a diamond pickaxe you would have to work backwards.

  1. The modified enchantment level for Silk Touch is 15–65.
  2. To guarantee that there will be a chance of getting Silk Touch, use the worst-case scenario: the modified level after step 1 would be reduced by 15%, meaning that this level would need to be at least 15 ÷ 0.85 = 18 (rounded to the nearest integer).
  3. A diamond pickaxe's enchantability is 10 (this actually isn't needed to calculate a guaranteed number of bookshelves).
  4. The worst-case scenario will be that in the first modifier, 0 will be chosen (from 0 to half the enchantability). This number + 1 will be added to the base enchantment level, meaning that the base enchantment level will be 18 - 0 - 1 = 17.
  5. Looking at the first table, it can be seen that at least 9 bookshelves are required to get Silk Touch in at least the third slot (the number of bookshelves where all the possible levels will be greater than or equal to 17). I also found that the number of bookshelves is the base enchantment level ÷ 2 rounded up.

TLDR: The number of levels required is (lowest modified enchantment level for enchantment) ÷ 0.85 - 1. The number of bookshelves is the number of levels ÷ 2 rounded down.


Here's info on the number of bookshelves and levels required for each enchantment:

Enchantment Levels Bookshelves
Aqua Affinity I 0 0
Bane of Arthropods I 5 3
Bane of Arthropods II 14 7
Bane of Arthropods III 24 12
Bane of Arthropods IV 33 17
Bane of Arthropods V 43 22
Blast Protection I 5 3
Blast Protection II 14 7
Blast Protection III 24 12
Blast Protection IV 33 17
Channeling I 28 14
Depth Strider I 11 6
Depth Strider II 23 12
Depth Strider III 34 17
Efficiency I 0 0
Efficiency II 12 6
Efficiency III 24 12
Efficiency IV 35 18
Efficiency V 47 24
Feather Falling I 5 3
Feather Falling II 12 6
Feather Falling III 19 10
Feather Falling IV 26 13
Fire Aspect I 11 6
Fire Aspect II 34 17
Flame I 23 12
Fortune I 17 9
Fortune II 27 14
Fortune III 38 19
Frost Walker I 11 6
Frost Walker II 23 12
Impaling I 0 0
Impaling II 10 5
Impaling III 19 10
Impaling IV 28 14
Impaling V 38 19
Infinity I 23 12
Knockback I 5 3
Knockback II 28 14
Looting I 5 3
Looting II 27 14
Looting III 38 19
Loyalty I 19 10
Loyalty II 25 13
Loyalty III 31 16
Luck of the Sea I 17 9
Luck of the Sea II 27 14
Luck of the Sea III 38 19
Lure I 17 9
Lure II 27 14
Lure III 38 19
Multishot I 0 0
Piercing I 3 2
Piercing II 23 12
Piercing III 43 22
Piercing IV 63 32
Power I 0 0
Power II 12 6
Power III 24 12
Power IV 35 18
Power V 47 24
Projectile Protection I 3 2
Projectile Protection II 10 5
Projectile Protection III 17 9
Projectile Protection IV 24 12
Protection I 0 0
Protection II 13 7
Protection III 26 13
Protection IV 39 20
Punch I 13 7
Punch II 37 19
Quick Charge I 17 9
Quick Charge II 27 14
Quick Charge III 38 19
Respiration I 11 6
Respiration II 23 12
Respiration III 34 17
Riptide I 19 10
Riptide II 31 16
Riptide III 43 22
Sharpness I 0 0
Sharpness II 13 7
Sharpness III 26 13
Sharpness IV 39 20
Sharpness V 52 26
Silk Touch I 17 9
Smite I 5 3
Smite II 14 7
Smite III 24 12
Smite IV 33 17
Smite V 43 22
Sweeping Edge I 5 3
Sweeping Edge II 15 8
Sweeping Edge III 26 13
Thorns I 11 6
Thorns II 34 17
Thorns III 58 29
Unbreaking I 5 3
Unbreaking II 14 7
Unbreaking III 24 12

Original gist predating tables in StackExchange