Pierce01 / MinecraftLauncher-core

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

launcher cant download .JAR for custom version #88

Open arduinka55055 opened 2 years ago

arduinka55055 commented 2 years ago

it happens because custom versions use inheritsFrom, so need to read original version and merge with custom.

My solution that works: change handler.js, line 106, getVersion:

return new Promise(resolve => {
  const versionJsonPath = this.options.overrides.versionJson ||
      path.join(this.options.directory, `${this.options.version.number}.json`)
  if (fs.existsSync(versionJsonPath)) {
      let version = JSON.parse(fs.readFileSync(versionJsonPath))

      if (version.inheritsFrom != null) {//my solution

          this.options.overrides.versionJson = undefined;
          this.getVersion(version.inheritsFrom).then((parentt) => {
              this.version = {...version, ...parentt };
              return resolve(this.version);
          });

      } else {
              this.version = version;
              return resolve(version);
      }
  }

also need to set this.options.overrides.versionJson to custom version instead original version number, tho it is possible to do in configs.

that will make library launch forge and fabric without any problems!

Pierce01 commented 2 years ago

I'll look into this when I have the chance. Thank you!

Pierce01 commented 2 years ago

I'm a little confused, when providing a valid custom version json from fabric's website, everything downloads fine. Adding on, there's already native support for Forge.

This line here: https://github.com/Pierce01/MinecraftLauncher-core/blob/master/components/handler.js#L511 Allows custom libraries to download and get added to the final launch arguments.

Can you provide the version json you're providing that requires this fix?

arduinka55055 commented 2 years ago

i am sorry, it doesnt download JAR, libraries are ok, wrong description the version is minecraft-launcher-core@3.16.12

https://i.imgur.com/WOmdnr4.jpg

Pierce01 commented 2 years ago

You should be using the technic format for the version json, as that file follows the vanilla version json structure. What version json for fabric are you using?

arduinka55055 commented 2 years ago

as you may see it has only libs required by fabric, no downloads. inheritsFrom probably says to use 1.18.2 as some kind of dependency. merging fabric-loader and vanilla jsons solve that problem

{
    "id": "fabric-loader-0.13.3-1.18.2",
    "inheritsFrom": "1.18.2",
    "releaseTime": "2022-04-18T08:29:14+0000",
    "time": "2022-04-18T08:29:14+0000",
    "type": "release",
    "mainClass": "net.fabricmc.loader.impl.launch.knot.KnotClient",
    "arguments": {
        "game": [],
        "jvm": [
            "-DFabricMcEmu= net.minecraft.client.main.Main "
        ]
    },
    "libraries": [
        {
            "name": "net.fabricmc:tiny-mappings-parser:0.3.0+build.17",
            "url": "https://maven.fabricmc.net/"
        },
        {
            "name": "net.fabricmc:sponge-mixin:0.11.2+mixin.0.8.5",
            "url": "https://maven.fabricmc.net/"
        },
        {
            "name": "net.fabricmc:tiny-remapper:0.8.1",
            "url": "https://maven.fabricmc.net/"
        },
        {
            "name": "net.fabricmc:access-widener:2.1.0",
            "url": "https://maven.fabricmc.net/"
        },
        {
            "name": "org.ow2.asm:asm:9.2",
            "url": "https://maven.fabricmc.net/"
        },
        {
            "name": "org.ow2.asm:asm-analysis:9.2",
            "url": "https://maven.fabricmc.net/"
        },
        {
            "name": "org.ow2.asm:asm-commons:9.2",
            "url": "https://maven.fabricmc.net/"
        },
        {
            "name": "org.ow2.asm:asm-tree:9.2",
            "url": "https://maven.fabricmc.net/"
        },
        {
            "name": "org.ow2.asm:asm-util:9.2",
            "url": "https://maven.fabricmc.net/"
        },
        {
            "name": "net.fabricmc:intermediary:1.18.2",
            "url": "https://maven.fabricmc.net/"
        },
        {
            "name": "net.fabricmc:fabric-loader:0.13.3",
            "url": "https://maven.fabricmc.net/"
        }
    ]
}
Pierce01 commented 2 years ago

I apologize for the late response, I was dealing with finals. For now, use the technic version json (which is right under where you got this one) since that one is properly formatted. I'll go ahead and add this to my todo list on version json formats to support