Added minecraft_launcher_lib, created skeleton for final product
This commit is contained in:
parent
2e33439b6c
commit
e52cfe6ee7
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,6 @@
|
||||
venv
|
||||
.idea
|
||||
logs
|
||||
|
||||
*.jar
|
||||
*.jar
|
||||
*.log
|
@ -2,9 +2,24 @@ import zipfile
|
||||
import json
|
||||
import sys
|
||||
import logging
|
||||
import minecraft_launcher_lib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# action plan for final product:
|
||||
# 1) Get a list of mod jars from a directory
|
||||
# 2) Install appropriate version of minecraft if it is not already installed
|
||||
# 3) Install appropriate version of minecraft forge if it is not already installed
|
||||
# 4) Launch empty version of minecraft forge to generate boilerplate file structure
|
||||
# 5) Exit the process after it launches successfully
|
||||
# 6) For each Jar:
|
||||
# a) Copy jar to directory
|
||||
# b) Attempt to launch the game
|
||||
# c) Record whether or not the game successfully launched/built/etc
|
||||
# d) If the game failed to launch, mark the jar as disabled
|
||||
# e) Continue to next jar
|
||||
|
||||
|
||||
class MinecraftMod:
|
||||
def __init__(self, fileName, filePath, modid, parentMods=None):
|
||||
self.parentMods = parentMods or []
|
||||
@ -40,6 +55,47 @@ def get_modpack_info(target_dir: Path):
|
||||
raise e
|
||||
|
||||
|
||||
def get_forge_version(minecraft_version: str):
|
||||
return minecraft_launcher_lib.forge.find_forge_version(minecraft_version)
|
||||
|
||||
|
||||
# potentially unnecessary, could substitue with run_forge_installer(version) instead of doing it all in the background?
|
||||
def install_forge_for_version(minecraft_version: str):
|
||||
minecraft_launcher_lib.forge.install_forge_version(
|
||||
get_forge_version(minecraft_version),
|
||||
path=minecraft_launcher_lib.utils.get_minecraft_directory()
|
||||
)
|
||||
|
||||
|
||||
def launch_minecraft():
|
||||
# see https://pypi.org/project/minecraft-launcher-lib/
|
||||
# We now have a way to automatically install and launch minecraft forge versions via python
|
||||
acct_resp = minecraft_launcher_lib.account.login_user(
|
||||
input("Enter your minecraft username"),
|
||||
input("Enter your minecraft password")
|
||||
)
|
||||
options = {
|
||||
# This is needed
|
||||
"username": acct_resp['selectedProfile']['name'],
|
||||
"uuid": acct_resp['selectedProfile']['id'],
|
||||
"token": acct_resp['accessToken'],
|
||||
# This is optional
|
||||
"executablePath": "java", # The path to the java executable
|
||||
"jvmArguments": [], # The jvmArguments
|
||||
"launcherName": "minecraft-launcher-lib", # The name of your launcher
|
||||
"launcherVersion": "1.0", # The version of your launcher
|
||||
"gameDirectory": r"C:\Users\VY Canis Majoris\AppData\Roaming\.moddedminecraft\1.12\1.12.2\test", # The gameDirectory (default is the path given in arguments)
|
||||
"demo": False, # Run Minecraft in demo mode
|
||||
"customResolution": False, # Enable custom resolution
|
||||
"resolutionWidth": "854", # The resolution width
|
||||
"resolutionHeight": "480", # The resolution heigth
|
||||
# "server": "example.com", # The ip of a server where Minecraft connect to after start
|
||||
# "port": "123", # The port of a server where Minecraft connect to after start
|
||||
# "nativesDirectory": "minecraft_directory/versions/version/natives" # The natives directory
|
||||
# "enableLoggingConfig": False, # Enable use of the log4j configuration file
|
||||
}
|
||||
|
||||
|
||||
def main(directory=Path('.')):
|
||||
modpack_info = list(get_modpack_info(directory))
|
||||
root_mods = [mp for mp in modpack_info if not mp.parentMods]
|
||||
@ -48,7 +104,10 @@ def main(directory=Path('.')):
|
||||
mod_tree = []
|
||||
for root_mod in root_mods:
|
||||
mod_tree.append({
|
||||
root_mod.modid: [mod.modid for mod in dependant_mods if root_mod.modid in mod.parentMods]
|
||||
root_mod.modid:
|
||||
{
|
||||
'depends_on': [mod.modid for mod in dependant_mods if root_mod.modid in mod.parentMods]
|
||||
}
|
||||
})
|
||||
|
||||
print(json.dumps(mod_tree, indent=4))
|
||||
|
Loading…
x
Reference in New Issue
Block a user