https://github.com/abdxdev/minecraft-hotkey-map
This project is for CS50P final week as well as my first project in python. :add
https://github.com/abdxdev/minecraft-hotkey-map
Last synced: about 2 months ago
JSON representation
This project is for CS50P final week as well as my first project in python. :add
- Host: GitHub
- URL: https://github.com/abdxdev/minecraft-hotkey-map
- Owner: abdxdev
- License: bsd-3-clause
- Created: 2023-09-16T06:16:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-16T15:59:54.000Z (2 months ago)
- Last Synced: 2025-03-18T11:48:22.674Z (2 months ago)
- Language: Python
- Homepage:
- Size: 1.45 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Minecraft Hotkey Chart Generator

## Video Demo:
[](https://www.youtube.com/watch?v=SlrZR0yFiYM)
## Requirements:
1. Make sure you have downloaded the code to your own Windows computer.
2. Make sure you have Minecraft game installed on your Windows computer.
3. Make sure you have an active internet connection.## Program Description:
### Overview:
This Program generates a customized Minecraft hotkey chart in either SVG or PNG format. It does so by parsing an SVG template, extracting keybindings and modifiers from the Minecraft game configuration, and then updating the SVG template with the customized keybindings.### Here's a detailed breakdown of the code:
#### 1. Importing Libraries:
- `requests` for making HTTP requests to download the SVG template.
- `xml.etree.ElementTree` as `ET` for parsing and manipulating SVG data.
- `re` for regular expression operations.
- `os` for working with the file system.
- `sys` for system-related operations.
- `cairosvg` for converting SVG to PNG.
- `colr` for color manipulation in CLI.#### 3. Defining Parameters:
- Various parameters such as `output_file_name`, `input_SVG_link`, `input_file_name`, `mod_colors`, and `key_list` are defined. These parameters determine the output file name, source SVG link, mod colors, and a list of Minecraft keys.#### 4. Reading Minecraft Keystrokes:
- The program attempts to open the Minecraft options file (`options.txt`) to extract keystrokes and their associated actions. If the file is not found, it exits with an error message.#### 5. Extracting Keystrokes:
- The program parses each line of the options.txt file of the game using regular expressions to extract keybindings and associated actions. It categorizes them into modded or vanilla actions.#### 6. Customizing Color Scheme:
- The program allows the user to customize the color scheme for the hotkey chart interactively. It prompts the user to choose colors for various elements such as:
- Background
- Header Text
- Custom Keys Frame
- Mouse Frame
- Keyboard Frame
- Mods Section Frame
- Keyboard Key
- Default Text#### 7. Choosing Output Format:
- The user is prompted to choose between generating an SVG or PNG file. If PNG is selected, the user can specify a scale factor for the image.#### 8. Applying Color Scheme:
- The program applies the chosen color scheme to the SVG file by modifying the relevant attributes in the SVG XML data.#### 9. Matching Keybindings:
- The program matches the extracted keybindings with their corresponding text representations in the SVG file and updates them.#### 10. Writing Output File:
- Depending on the chosen output format (SVG or PNG), the program either writes the modified SVG file or converts it to PNG using CairoSVG. Temporary SVG files are created during this process and cleaned up afterward.#### 11. Functions:
- `cleanup()` A utility function to remove duplicates from a list of modnames.
- `combine()` A utility function to combine two lists into a dictionarywhere elements from the first list are keys and elements from the secondlist are values.
- `getUserPath()` A function that returns the path to the Minecraftoptions file in the user's APPDATA directory.
- `change_color()` A function that allows the user to input a colorvalue in hexadecimal format (#RRGGBB) and validates it. It returns theselected color.### Summary:
This program not only takes Minecraft keybindings but also the mods used to modify the base game, from the game's configuration file and combines them with an SVG template, customizes the appearance of the hotkey chart and outputs it in the user's preferred format (SVG or PNG). It offers a way for Minecraft players to create visual hotkey charts for reference while playing the game.[](https://www.buymeacoffee.com/abdbbdii)

