Giter Club home page Giter Club logo

Comments (3)

Seeroy avatar Seeroy commented on June 2, 2024

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);
});

from minecraftlauncher-core.

elmWilh avatar elmWilh commented on June 2, 2024

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.

from minecraftlauncher-core.

Pierce01 avatar Pierce01 commented on June 2, 2024

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.

from minecraftlauncher-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.