HomeJavaModsEnchantment Calculator
Enchantment Calculator
ModsJava

Enchantment Calculator

by FanyaOff · on Modrinth

Client-side mod that calculates optimal enchantment paths to save XP and levels when enchanting gear, tools, weapons, and armor.

Which Minecraft do you have?

Every version of the game needs its own build. Pick yours, then download — the wrong build installs fine and then does nothing in the game. This mod is built for Fabric only.

⬇ Download for 1.21.9–1.21.10⬇ Download for 1.21.6–1.21.8⬇ Download for 1.21.2–1.21.5⬇ Download for 1.21–1.21.1
I don't know my version or loader
Open the Minecraft launcher and look at the profile you play on — it names both, like fabric-loader-1.21.4. The version also shows in the bottom-right corner of the game's main menu.
No loader in the profile name? Then it's plain Minecraft, and these mods won't run — you need Fabric or NeoForge installed first.

Overview

Enchantment Calculator is a client-side mod that helps you find the most cost-effective way to combine enchantments on your items.

This mod is based on the functionality provided by this website

This mod supports customization via a custom resource pack. GUI elements are located at: assets/enchantmentcalculator/textures/gui

You can view the original textures in the source code on GitHub

If you have an idea to improve the interface by redrawing the elements or by changing the code, I would appreciate it.

Known bugs

Bug Reports & Feature Requests

Found a bug, errors in calculations, have a suggestion? Please report it my our GitHub Issues page.

Usage

  1. Place an item in the anvil
  2. Select enchantments from the left panel
  3. Click Calculate to find the optimal sequence
  4. Follow the steps shown in the right panel
  5. Navigate through steps using arrow buttons

Screenshot

image

Technical Algorithm Overview

Optimization Algorithm

The Enchantment Calculator uses a sophisticated tree-based optimization algorithm to find the most cost-effective enchanting sequence.

Core Algorithm Steps:

1. Tree Structure Generation

For n enchantments, generate all possible binary combination trees
- Each leaf = enchantment book or base item
- Each internal node = anvil combination operation
- Tree depth determines maximum prior work penalty

2. Cost Calculation Model

The mod calculates costs using Minecraft's exact anvil mechanics:

Total Cost = Enchantment Cost + Prior Work Penalty

Where:

3. Tree Pruning Optimization

Instead of testing all possible trees, the algorithm:

4. Item Placement Optimization

For each tree structure:

1. Sort enchantment books by cost (expensive first)
2. Calculate leaf contribution values for each position
3. Place expensive items at positions with lowest contributions
4. Minimize total weighted cost

5. Multi-Mode Optimization

Supports two optimization targets:

Mathematical Foundation

Prior Work Penalty Calculation:

penalty = MULTIPLIERS[left_item_uses] + MULTIPLIERS[right_item_uses]

Experience Cost Conversion:

if (levels ≤ 16): xp = levels² + 6×levels
if (levels ≤ 31): xp = 2.5×levels² - 40.5×levels + 360
if (levels > 31): xp = 4.5×levels² - 162.5×levels + 2220

Tree Contribution Weighting:

For each tree position i:
contribution[i] = depth_from_root
weighted_sum = Σ(i × contribution[i])

Algorithm Complexity

Enchantment Weight System

The mod uses empirically determined weights matching Minecraft's internal costs:

Weight 1: protection, sharpness, efficiency, unbreaking, power
Weight 2: fire_aspect, looting, fortune, punch, flame
Weight 4: mending, silk_touch, infinity, curse_of_binding

Tree Search Strategy

  1. Generate all possible binary tree structures
  2. Filter by maximum depth to reduce search space
  3. Score each tree using weighted contribution analysis
  4. Select optimal trees per depth level
  5. Test item placements for each selected tree
  6. Return globally optimal solution

Edge Case Handling

This algorithm ensures you get the mathematically optimal enchanting sequence while maintaining fast performance suitable for real-time gameplay.

Quick facts

Install steps are the general flow for this file type — see the MC Java Mods guides for the full walkthrough.

Verified by MCModsHub

These come from our own check of the pack file, not from the source page.

Explore more