GameHub icon indicating copy to clipboard operation
GameHub copied to clipboard

[Feature] Importing MultiMC instances

Open LordMZTE opened this issue 2 years ago • 3 comments

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:

  • minecraft or .minecraft: the actual data of the minecraft instance, shouldn't be important to GameHub
    • this directory (for some reason) also contains the instance icon in a file called icon.png. GameHub should show this.
  • mmc-pack.json: contains some data of the components of the minecraft setup, including the minecraft version and things like modloaders if installed. Some of this information might be helpful if it was displayed in GameHub, but nothing all that important.
  • instance.cfg: an ini-style file which contains some important metadata, like the name of the instance. This will be important for GameHub.

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

LordMZTE avatar Oct 12 '21 12:10 LordMZTE

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:

  • Executable: /path/to/multimc
  • Arguments: --launch $file $game_args (assuming --launch can accept a file path)
  • Executable pattern: ./mmc-pack.json|./instance.cfg (or something inside of the instance dir that can be passed to multimc)
  • Icon pattern: ./minecraft/icon.png|./.minecraft/icon.png

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

tkashkin avatar Oct 12 '21 14:10 tkashkin

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 avatar Oct 12 '21 14:10 LordMZTE

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

  • Executable: /home/username/.local/bin/gamehub_multimc
  • Arguments: $file $game_args
  • Executable Patter: ./instance.cfg
  • Image & Icon: ./minecraft/icon.png|./.minecraft/icon.png

And using this script:

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

LordMZTE avatar Oct 12 '21 14:10 LordMZTE