Pierce01 / MinecraftLauncher-core

Lightweight module that downloads and runs Minecraft using javascript / NodeJS
MIT License
356 stars 81 forks source link

[BUG] Error when we're launching Minecraft with `options.version.custom` to `fabric` #107

Closed pioupia closed 1 year ago

pioupia commented 1 year ago

Describe

When running the game with the options.version.custom option set to fabric, the module downloads the correct version of the loader json file, under the name : ${minecraft_version}.json.

However, when loading the file, it tried to load the ${options.version.custom}.json file, which caused an error and prevented the game from launching.

How to reproduce the bug

Just set the value of the version.custom option to fabric.

For example:

const { Client, Authenticator } = require('minecraft-launcher-core');
const launcher = new Client();

let opts = {
    // For production launchers, I recommend not passing 
    // the getAuth function through the authorization field and instead
    // handling authentication outside before you initialize
    // MCLC so you can handle auth based errors and validation!
    authorization: Authenticator.getAuth("username", "password"),
    root: "./minecraft",
    version: {
        number: "1.18.2",
        type: "release",
        custom: "fabric"
    },
    memory: {
        max: "6G",
        min: "4G"
    }
}

launcher.launch(opts);

launcher.on('debug', (e) => console.log(e));
launcher.on('data', (e) => console.log(e));

The error

debug :  [MCLC]: Failed to start due to Error: ENOENT: no such file or directory, open '/home/pioupia/.config/launcher/.minecraft/versions/fabric/fabric.json', closing...

Then the game does not start.

Additional information:

I made a pull request that solves the problem, if you want to see : #106