Skip to main content

A small python module that masters Minecraft enchanting mechanics.

Project description

MC-Enchanter

Description

MC-Enchanter is a simple python program that simulates the enchantment mechanics of the anvil in the popular game: Minecraft. It's based on the Official Minecraft Wiki page: Anvil/Mechanics.

Motivation

Let's say that you wanted a powerfull axe with all of the following enchantements: Sharpness V, Efficiency V, Silk Touch and Unbreaking III. Suppose that you got all corresponding enchanted books and you applied them one after the other to the axe using an anvil. You'll end up with a total cost of 28 EXP. But if you combined Silk Touch I and Unbreaking III first, and then you applied the rest of books then it will cost you 25 EXP. This motivated me to write this program that by giving it the enchanted books you have, and the desired enchanted item, it gives you the cheapest (possible) books combination.

Features

  • Calculate the exact total experience cost of any enchantment.
  • Find the minimum experience cost for a specific enchantements combination using enchanted books only.
  • Find the minimum experience cost for a specific enchantements combination using enchanted books and items.
  • Support items durability.
  • Build a nice gui.

Instalation

After downloading Python 3.6+, use the following pip command:

pip install --upgrade mc-enchanter

Example

Let's take the example used in Motivation

from mc_enchanter import *

axe = EnchantableItem([], "axe")

unbreaking3 = EnchantedBook([ Enchantment('Unbreaking', 3) ])
sharpness5 = EnchantedBook([ Enchantment('Sharpness', 5) ])
efficiency5 = EnchantedBook([ Enchantment('Efficiency', 5) ])
silk_touch = EnchantedBook([ Enchantment('Silk Touch', 1) ])

enchantedBooks = [unbreaking3, sharpness5, efficiency5, silk_touch]
combination = BestBooksEnchantmentCombination(axe, enchantedBooks)

print(combination)

Output

[25, ((axe, Book(Sharpness V), 5), (axe, Book(Efficiency V), 6), (axe, Book(Book(Silk Touch I)+Book(Unbreaking III),3), 11))]
 ^ The    | ^_> Combine the axe    |  ^_> Combine the axe       |    ^_> 1- Combine Book(Silk Touch I) with Book(Unbreaking III) costs 3 EXP
 cheapest | with Book(Sharpness V) |  with Book(Efficiency V)   |     2- Combine axe with the resulting book: Book(Book(Silk Touch I)+Book(Unbreaking III),3)
   cost   |     costs 5 EXP        |      costs 6 EXP           |                            costs 11 EXP

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mc_enchanter-0.0.5.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mc_enchanter-0.0.5-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file mc_enchanter-0.0.5.tar.gz.

File metadata

  • Download URL: mc_enchanter-0.0.5.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5

File hashes

Hashes for mc_enchanter-0.0.5.tar.gz
Algorithm Hash digest
SHA256 fddf77b22390199d887f1d2f7a25ed57cc6185a8ac1a93cb9cb2ad27e9b86d93
MD5 5326ef47b5f42cae769228ae121afa3f
BLAKE2b-256 8eb61c84df301ddae85e659a2126a5cd688ab7485e109f643d847a274c507368

See more details on using hashes here.

File details

Details for the file mc_enchanter-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: mc_enchanter-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5

File hashes

Hashes for mc_enchanter-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a293d448c45b3110f7a450a1407a0cc63a28a3bf21a20d55999b9f3e82efcc85
MD5 603d39691254aae7367250f92df9dfdd
BLAKE2b-256 60b5cc938f273510856274e1bbde37f4ce61ad365ded2742c61330938dfc8383

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page