tkashkin / GameHub

All your games in one place
https://tkashkin.github.io/projects/gamehub
GNU General Public License v3.0
2.23k stars 129 forks source link

[Feature] Importing MultiMC instances #576

Open LordMZTE opened 2 years ago

LordMZTE commented 2 years ago

It would be amazing if GameHub would support importing minecraft instances from the MultiMC minecraft launcher.

This shouldn't be too hard to implement, as we could simply get the directories in the instances directory, which is set in the config file at ~/.local/share/multimc/multimc.cfg.

This file has an ini-like format, and contains this line if the user is using a custom location for storing instances:

InstanceDir=xxx

Note that this path is relative too ~/.local/share/multimc, and that the key is not present by default, in which case the launcher defaults to ~/.local/share/multimc/instances.

Then, we could enumerate the contents of that directory. Each minecraft instance has its own directory, which contains these files:

EDIT: an instance can be launched by invoking multimc --launch <instance_id> where the instance ID is the name of the instance's directory.

tkashkin commented 2 years ago

I'm not sure this feature is in scope of the project and even if it was it would have low priority. Maybe it could be implemented some time in the future if there's demand for it.

However if MultiMC can launch instances by path of some file instead of the instance id, you can try to set that up as a custom emulator and try Import emulated games feature:

Then click + in the main window, open Import emulated games dialog, set path to ~/.local/share/multimc/instances and import.

LordMZTE commented 2 years ago

Thanks! Unfortunately, MultiMC doesn't accept a file path as a launch argument, but that should be easy to fix with a simple shellscript. Thanks for explaining the custom emulators feature. Feel free to close this issue.

LordMZTE commented 2 years ago

For anyone else who might be interested in doing this, I managed to get it work with these settings:

And using this script:

#!/bin/sh
inst_id=$(echo $1 | awk -F/ '{print $(NF-1)}')
multimc --launch "$inst_id" "${@:2}"