Pierce01 / MinecraftLauncher-core

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

Can`t run Forge <1.13 #114

Closed Seeroy closed 1 year ago

Seeroy commented 1 year ago

Hi. I'm making my own Minecraft launcher using your library. The documentation for your library says that in options.forge before version 1.13 you need to specify the universal file, but in this case pure vanilla minecraft is launched only

Seeroy commented 1 year ago

My example code

const { Client } = 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: {
      access_token: '',
      client_token: '',
      uuid: '',
      name: 'testusr',
      user_properties: '{}',
      meta: {
          type: 'mojang',
          demo: false,
      }
  },
    root: "./mctest",
    forge: "./forge-1.12.2-14.23.5.2860-universal.jar",
    version: {
        number: "1.12.2",
        type: "release"
    },
    memory: {
        max: "6G",
        min: "4G"
    }
}

launcher.launch(opts);

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

launcher.on('progress', function (e) {
  console.log("======> ", e.task, " ИЗ ", e.total);
});

launcher.on('download-status', function (e) {
  console.log(e.name, ">", e.current, " ИЗ ", e.total);
});
elmWilh commented 1 year ago

However, since you are trying to launch Forge for 1.12.2, the system is a little bit different. Instead of specifying the jar file, you should use the Client function to install Forge for you, and then you can use the installed Forge version to launch the game.

Here is a simple example of how you might do this:

const launcher = new Client();

let opts = {
    authorization: {
      access_token: '',
      client_token: '',
      uuid: '',
      name: 'testusr',
      user_properties: '{}',
      meta: {
          type: 'mojang',
          demo: false,
      }
  },
    root: "./mctest",
    version: {
        number: "1.12.2-forge1.12.2-14.23.5.2859",
        type: "release"
    },
    memory: {
        max: "6G",
        min: "4G"
    }
};

const installer = new Installer({ 
  root: "./mctest",
  version: "1.12.2",
  forge: '14.23.5.2859'
});

installer.install('forge')
  .then(() => {
    console.log('Forge installed');
    launcher.launch(opts);
  })
  .catch(console.error);

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

launcher.on('progress', function (e) {
  console.log("======> ", e.task, " ИЗ ", e.total);
});

launcher.on('download-status', function (e) {
  console.log(e.name, ">", e.current, " ИЗ ", e.total);
});

I'm not sure if this will work, but give it a try. It should work.

Pierce01 commented 1 year ago

Hey Seeroy, use the installer jar when trying to launch forge with 1.12.2 past installer version 2847, as the universal jar for 1.12.2 uses a different installer system.