portablemc
portablemc copied to clipboard
Custom client load in API
Hi, i tried to load a custom client and from command line i can, but i can't with the API, is possible to use the API for load a custom client?
By custom client you mean with a specific version identifier (in versions directory) ?
yes
This should work, can you give the code you used?
Please re-open this issue if you have further issues
oh, sorry, i did not notice the response from you, but, im just using the code from the api documentation
Honestly, I can't do much without a bit of code, without it, I can't understand from where can come the problem, if it's obvious or not...
from portablemc import Context, VersionManifest, StartOptions, Start
import os
main_dir = "{}\\.minecraft".format(os.environ.get('APPDATA'))
work_dir = "{}\\.minecraft".format(os.environ.get('APPDATA'))
ctx = Context(main_dir, work_dir)
print(ctx.work_dir)
print(ctx.versions_dir)
print(ctx.assets_dir)
print(ctx.libraries_dir)
print(ctx.jvm_dir)
print(ctx.bin_dir)
cache_file = "{}\\.minecraft\\manifest.json".format(os.environ.get('APPDATA'))
cache_timeout = 5.0
manifest = VersionManifest(cache_file, cache_timeout)
start_opts = StartOptions()
start_opts.disable_multiplayer = True
start_opts.username = "FrostCraftUser"
start_opts.resolution = (700, 500)
start = Start("1.8.9")
start.prepare(start_opts)
start.main_class = "net.minecraft.client.main.Main"
start.jvm_args.append("-Dmy.jvm.arg=89")
start.start()

Ok, almost ready to work :) The issue here is that Start() constructor requires a Version object, not a str.
version = Version(ctx, "1.8.9")
version.install() # to initialize the version and install missing libraries (and JVM if you need using `jvm=True` argument)
start = Start(version)
# [...]