Minecraft anvil mechanics explained
Every multiplier, penalty, and edge case in the anvil cost formula - with examples you can re-run in the calculator.
The full cost formula
total_xp_cost = sum_over_enchants(bookMultiplier * result_level)
+ prior_work_penalty(target)
+ prior_work_penalty(sacrifice)
+ repair_material_cost
prior_work_penalty(n) = 2^n - 1
Read carefully: the cost contribution per enchantment uses the result level on the merged item, not the sacrifice's level. Sharpness IV + Sharpness IV upgrades to Sharpness V (cost 5), not to a second Sharpness IV (cost 4).
Book vs item multipliers
Each enchantment has a book multiplier and (implicitly) an item multiplier at half (rounded up, minimum 1). The anvil uses the book multiplier when the sacrifice is a book and the item multiplier when the sacrifice is a sacrificed gear piece. This is why books are nearly always cheaper than item-on-item combines.
| Enchant | Book mult | Item mult |
|---|---|---|
| Sharpness | 1 | 1 |
| Smite | 2 | 1 |
| Fortune | 4 | 2 |
| Silk Touch | 8 | 4 |
| Thorns | 8 | 4 |
| Mending | 4 | 2 |
The prior-work penalty (2^n - 1)
Every anvil use increments the prior-work counter on the resulting item by 1. The penalty for the next anvil use scales exponentially:
| Prior-work n | Penalty |
|---|---|
| 0 (new) | 0 |
| 1 | 1 |
| 2 | 3 |
| 3 | 7 |
| 4 | 15 |
| 5 | 31 |
| 6 | 63 |
Both inputs contribute their penalty to the cost - which is why combining two high-prior-work items is borderline impossible without triggering 'Too Expensive!'.
Conflicts and incompatibilities
Modern Minecraft (1.14+) refuses any combine where the sacrifice's enchantments include one that conflicts with the target's. The classic examples: Sharpness vs Smite vs Bane of Arthropods on swords; Silk Touch vs Fortune on tools; Infinity vs Mending on bows; Loyalty vs Riptide on tridents; Density vs Breach on the mace (1.21+).
1.20+ vs Legacy
The August 2023 update (1.20) tweaked the way the anvil charges multi-book chains. The cap stayed at 40 - what changed is which merge orders are cheap. Specifically, book-pair-first plans got relatively cheaper because the prior-work growth on book-pair-first plans stays lower for longer. The calculator toggle switches between the 1.20+ accounting and the pre-1.20 'Legacy' accounting.