Step 1: Bookshelf Detection, Air-Gap Occlusion & Slot Levels
Before rolling a single enchantment, EnchantmentMenu scans the 32 block coordinates forming a 5×5 perimeter ring two blocks high around the Enchanting Table (|dx| == 2 or |dz| == 2 at dy = 0 and dy = +1) and clamps valid bookshelves at B = min(validShelves, 15). Inside EnchantingTableBlock.isValidBookShelf, every candidate shelf must pass a strict two-part check: the outer coordinate must hold a block tagged #minecraft:enchantment_power_provider (Bookshelf, not Chiseled Bookshelf!), and the intermediate gap coordinate at (dx / 2, dy, dz / 2) must satisfy isAir() (#minecraft:enchantment_power_transmitter).
While entity-based paintings and item frames do not replace the air block state in Java Edition, any placed block—including carpets, torches, candles, levers, buttons, string, snow layers, ladders, and water—fails isAir(); placing decorative carpets or lighting torches inside the 1-block moat around your table silently severs line-of-sight to up to three corner bookshelves at once! Technical players deliberately exploit this rule by wiring sticky pistons or placing removable torches in the gap when targeting mid-level enchantments without breaking shelves.
From valid shelf count B (0 ≤ B ≤ 15), the server rolls a base integer using your hidden xpSeed: base = randInt(1, 8) + floor(B / 2) + randInt(0, B). At B = 15, base spans [8, 30], feeding the three GUI slots:
- Slot 1 (Top, 1 Lapis):
max(floor(base / 3), 1)→ spans2to10at 15 shelves. - Slot 2 (Middle, 2 Lapis):
floor(base × 2 / 3) + 1→ spans6to21at 15 shelves. - Slot 3 (Bottom, 3 Lapis):
max(base, B × 2)→ atB = 15,B × 2 = 30forces Slot 3 to display a guaranteed 30 on every single item without re-inserting!
Step 2: Triangular Material Enchantability & Modified Level
Clicking a slot with displayed requirement L_slot (such as 30) triggers EnchantmentHelper.selectEnchantment. The game does not look up enchantments at level 30 directly; instead, it transforms L_slot through two consecutive triangular probability distributions governed by the item material's hidden enchantability stat (E):
q = floor(E / 4)
step1Level = L_slot + 1 + randInt(0, q) + randInt(0, q)
randomScale = 1.0 + (randFloat(0, 1) + randFloat(0, 1) - 1.0) × 0.15
modifiedLevel = max(1, round(step1Level × randomScale))
Summing two independent uniform random integers in [0, floor(E/4)] creates a discrete triangular distribution centered at 1 + floor(E/4), which is then stretched by a continuous triangular ±15% multiplier ([0.85, 1.15]).
Notice how Iron and Gold split their enchantability values between tools/weapons and armor inside Mojang's item registries, and how Netherite strictly outperforms Diamond:
| Item Material | Tool / Weapon E | Armor E | floor(E / 4) | Slot 30 Modified Range | Mean Modified Level |
|---|---|---|---|---|---|
| Gold | 22 |
25 |
5 (Tool) / 6 (Armor) |
26–47 (Tool) / 26–49 (Armor) |
36.0 / 37.0 |
| Netherite / Wood / Leather / Mace | 15 |
15 |
3 |
26–43 |
34.0 |
| Iron | 14 |
9 |
3 (Tool) / 2 (Armor) |
26–43 (Tool) / 26–40 (Armor) |
34.0 / 33.0 |
| Chainmail | — | 12 |
3 |
26–43 |
34.0 |
| Diamond | 10 |
10 |
2 |
26–40 |
33.0 |
| Turtle Shell | — | 9 |
2 |
26–40 |
33.0 |
| Stone | 5 |
— | 1 |
26–38 |
32.0 |
| Book / Bow / Trident / Crossbow / Rod | 1 |
— | 0 |
26–36 |
31.0 |
Mathematical Proof: Why Diamond Tools Never Roll Efficiency V
Every non-treasure enchantment tier k defines an acceptance window [minCost(k), maxCost(k)] against modifiedLevel. For minecraft:efficiency, Mojang defines minCost(k) = 1 + 10 × (k - 1): Tier I starts at 1, II at 11, III at 21, IV at 31, and Efficiency V requires modifiedLevel ≥ 41.
Evaluate the absolute upper bound for a Diamond Pickaxe (E = 10) at L_slot = 30:
q = floor(10 / 4) = 2, so maximumstep1Level = 30 + 1 + 2 + 2 = 35.- Multiplying by the maximum
1.15scale yields35 × 1.15 = 40.25, which rounds viaMath.round(40.25)to exactly40! - Because
40 < 41, a Diamond Pickaxe, Axe, or Shovel has a strictly 0.00% probability of ever rolling Efficiency V on an Enchanting Table! - Conversely, upgrading that blank Diamond Pickaxe to Netherite (
E = 15,q = 3) in a Smithing Table before enchanting raises maximumstep1Levelto37, pushinground(37 × 1.15) = 43 ≥ 41and unlocking direct Efficiency V pulls without burning an anvil use! (Iron tools atE = 14also shareq = 3and reach43, as do Gold tools at47.)
Step 3: Selection Weights & Iterative Multi-Enchantment Decay
Once modifiedLevel fixes the candidate pool (retaining only the highest eligible tier of each compatible enchantment), Minecraft performs weighted sampling without replacement using P(pick i) = weight_i / Σ weight_j:
- Pickaxe Pool (
Σw = 18atmodifiedLevel = 34):Efficiency IV(weight10,55.6%),Unbreaking III(weight5,27.8%),Fortune III(weight2,11.1%— see Fortune III drop tables),Silk Touch I(weight1,5.6%). - Armor Chestplate Pool (
Σw = 28atmodifiedLevel = 34):Protection IV(weight10,35.7%— see Protection IV math),Fire Protection IV(5,17.9%),Projectile Protection IV(5,17.9%),Unbreaking III(5,17.9%),Blast Protection IV(2,7.1%), andThorns II(1,3.6%). - Sword Pool (Java
Σw = 36):Sharpness IV(10),Smite IV/V(5),Bane of Arthropods IV/V(5),Knockback II(5),Unbreaking III(5),Fire Aspect II(2),Looting III(2),Sweeping Edge III(2).
After locking in the first enchantment and purging mutually exclusive candidates (such as purging Silk Touch once Fortune is picked, or purging Smite/Bane once Sharpness is picked), the engine runs an iterative bonus loop:
- Roll with probability
(modifiedLevel + 1) / 50to grant an extra enchantment from the already-filtered high-tier candidate pool (atmodifiedLevel = 34, the second enchantment triggers35 / 50 = 70.0%of the time!). - Divide the loop counter in half via integer division:
modifiedLevel = floor(modifiedLevel / 2)(34 → 17, so a third enchantment rolls at18 / 50 = 36.0%, and a fourth rolls at9 / 50 = 18.0%). Because the candidate pool itself is never downgraded during this halving loop, your bonus third enchantment on a pickaxe is still full-tierFortune III+Unbreaking III+Efficiency IV(0.70 × 0.36 = 25.2%chance to land all three compatible pickaxe enchants at once!).
Java Edition (1.21.4)
Sword pools include Sweeping Edge (weight 2), slightly diluting Looting III first-pick odds (2/36 vs 2/34). Books rolling multiple enchantments at Slot 30 intentionally strip one random enchantment when 2+ are rolled (EnchantmentHelper book rule) to reduce omnibook clutter.
Bedrock Edition (1.21.50)
Uses the identical 15-bookshelf air-gap check, triangular enchantability math, and 40 vs 41 Diamond Efficiency V cutoff, but omits Sweeping Edge completely. Carpet or torch placement inside the 1-block perimeter ring disables shelves identically to Java.
/xp set @s 300 levels. Enchant 50 Diamond Pickaxes at Slot 30 (resetting xpSeed naturally on each craft): zero will ever display or roll Efficiency V. Upgrade 20 blank Diamond Pickaxes with Netherite Upgrade Smithing Templates first and roll Slot 30: roughly 1 in 18 rolls will pull Efficiency V directly off the table. Next, place 4 wool carpets in the corner air gaps around the table: Slot 3 immediately drops from 30 to 14–22.