Skip to content

A repository where you can find and generate Enchantment probability for Minecraft. It's still in development so there's a lot of stringy file management.

Notifications You must be signed in to change notification settings

SeeYou-Man/Minecraft-Enchantment-Probabilities

Repository files navigation

Minecraft Enchanting Simulator - Browser UI

Files added:

  • index.html : The web UI
  • styles.css : Styling
  • script.js : Logic + charting

How to run (recommended):

  1. Serve the folder over HTTP (browsers block fetch on local files). From the project folder run:
# Simple Python 3 http server
python -m http.server 8000
  1. Open your browser to: http://localhost:8000/index.html

  2. Use the dropdowns to select an item/material, choose enchant level and iterations, then click "Run Simulation".

Notes:

  • The site fetches items.json and enchantments.json from the same folder. Make sure those files are present.
  • Chart colours are taken from enchantments.json color fields.
  • The simulator uses the same general mechanics as the notebook/runner but is simplified to run in the browser. Iterations are limited to avoid freezing the page.

Next steps you may want:

  • Fill applicable_items arrays in enchantments.json to restrict enchantments to correct item groups.
  • Add server-side endpoints if you want to run very large simulations (offload work from the browser).
  • Add tooltips and nicer UX for chart details.

Python simulator (new)

  • The algorithmic simulator has been added at the repository root as enchant_simulator.py.
  • It implements Minecraft's enchanting-table algorithm (bookshelves → slot → enchantability modifiers → weighted selection, conflicts, extra-enchant iterations).

Quick examples (PowerShell):

# Run the small demo that prints a couple of sample draws
& ".venv\Scripts\python.exe" "./enchant_simulator.py"

# Use the simulator programmatically from a short script (example):
& ".venv\Scripts\python.exe" - <<'PY'
from enchant_simulator import EnchantSimulator
sim = EnchantSimulator()
print(sim.sample_by_modified_level('Helmet', 'Chain', 20, allow_treasure=False))
print(sim.sample_by_bookshelves('Sword', 'Diamond', 15, slot='bottom'))
PY

Validation runner

  • A helper script run_validation.py (repo root) runs Monte Carlo trials to sample the simulator. To run 3 validation runs of 10,000 trials each:
& ".venv\Scripts\python.exe" "./run_validation.py"

Notes

  • Table-mode generation excludes treasure-only enchants (controlled by the Treasure flag in Items_New_Probability/database.json). Treasure: true marks an enchant as treasure-only; such enchants are excluded from enchanting-table draws unless allow_treasure=True or the source explicitly permits treasure enchants (for example, Level-30 Books).
  • The new simulator uses enchantability values from Items_New_Probability/database.json.
  • Results will differ from Items_Old_Probability files because the enchant pool and metadata were expanded.

Armor-specific enchantability

  • For armor items (Helmet, Chestplate, Leggings, Boots, TurtleShell) the simulator will use the armorEnchantability value from Items_New_Probability/database.json when that key is present for a material. If armorEnchantability is missing the simulator falls back to the generic enchantability value. This ensures armor uses the intended, separate enchantability that differs from tools in some materials (for example Gold often has a higher armorEnchantability).

Example: to regenerate Helmet probabilities using base-level sampling (base-level 10) for all materials and levels 1..30 using 3 workers and 100k trials per level:

& ".venv\Scripts\python.exe" "./scripts/generate_new_probs.py" --mode base --items Helmet --materials Leather Chain Iron Diamond Gold Netherite --trials 100000 --workers 3 --all-levels --level 30 --seed 123

High-resolution graphs and site generation

The static site generator scripts/generate_enchant_site.py can produce per-enchant HTML pages and lightweight embedded SVG charts. It also supports producing high-resolution PNG graphs (useful for publishing or printing) when matplotlib and numpy are installed.

Install the optional dependencies:

pip install matplotlib numpy

Examples (PowerShell):

Basic generation (reads precomputed JSONs from Items_New_Probability):

.venv\Scripts\python.exe scripts/generate_enchant_site.py --use-existing --outdir web/enchant_tables_existing --levels 30

Embedded SVG graphs (lighter weight):

.venv\Scripts\python.exe scripts/generate_enchant_site.py --use-existing --outdir web/enchant_tables_existing --levels 30 --graphs

High-resolution PNG graphs (requires matplotlib):

.venv\Scripts\python.exe scripts/generate_enchant_site.py --use-existing --outdir web/enchant_tables_existing --levels 30 --hires-graphs --graph-dpi 200 --graph-width 2000 --graph-height 500

Notes:

  • --hires-graphs creates an assets/ folder next to each enchant directory and saves PNG files named by item/material anchors (e.g. Sword_Diamond.png).
  • If matplotlib is missing the script will skip PNG generation and continue producing HTML + embedded SVGs if requested.
  • Use --xp-formula pernsteiner (default) or --xp-formula simple to control XP cost computations used for estimated XP per attempt.

About

A repository where you can find and generate Enchantment probability for Minecraft. It's still in development so there's a lot of stringy file management.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages