mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-11-22 04:06:21 +03:00
Adding in support for older MC versions. Looking into sound issue
This commit is contained in:
parent
8e3d6751ae
commit
b21ddf1d63
3 changed files with 17 additions and 5 deletions
|
@ -1,5 +1,4 @@
|
|||
# Minecraft Launcher Core
|
||||
### Currently only supports MC 1.7.3 and up.
|
||||
|
||||
MCLC is a NodeJS solution for launching modded and vanilla Minecraft without having to download and format everything yourself.
|
||||
Basically a core for your Electron or script based launchers.
|
||||
|
|
|
@ -81,6 +81,7 @@ module.exports.getAssets = function (directory, version) {
|
|||
return new Promise(async(resolve) => {
|
||||
const assetsUrl = 'https://resources.download.minecraft.net';
|
||||
const failed = [];
|
||||
const parseVersion = version.assetIndex.id.split('.');
|
||||
|
||||
if(!fs.existsSync(path.join(directory, 'assets', 'indexes', `${version.assetIndex.id}.json`))) {
|
||||
await downloadAsync(version.assetIndex.url, path.join(directory, 'assets', 'indexes'), `${version.assetIndex.id}.json`);
|
||||
|
@ -97,6 +98,16 @@ module.exports.getAssets = function (directory, version) {
|
|||
const download = await downloadAsync(`${assetsUrl}/${subhash}/${hash}`, assetDirectory, hash);
|
||||
|
||||
if(download.failed) failed.push(download.asset);
|
||||
|
||||
if(parseVersion[1] < 8 && parseVersion[2] < 3) {
|
||||
let legacyAsset = asset.split('/')
|
||||
legacyAsset.pop()
|
||||
|
||||
if(!fs.existsSync(path.join(directory, 'assets', 'legacy', legacyAsset.join('/')))) {
|
||||
shelljs.mkdir('-p', path.join(directory, 'assets', 'legacy', legacyAsset.join('/')));
|
||||
fs.copyFileSync(path.join(assetDirectory, hash), path.join(directory, 'assets', 'legacy', asset))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,8 +228,10 @@ module.exports.getClasses = function (root, version) {
|
|||
|
||||
module.exports.getLaunchOptions = function (version, forge, options) {
|
||||
return new Promise(resolve => {
|
||||
let type = forge || version;
|
||||
let arguments = type.minecraftArguments ? type.minecraftArguments.split(' ') : type.arguments.game;
|
||||
const parseVersion = version.assetIndex.id.split('.');
|
||||
const type = forge || version;
|
||||
const arguments = type.minecraftArguments ? type.minecraftArguments.split(' ') : type.arguments.game;
|
||||
const assetPath = parseVersion[1] < 8 && parseVersion[2] < 3 ? path.join(options.root, 'assets', 'legacy') : path.join(options.root, 'assets');
|
||||
|
||||
const fields = {
|
||||
'${auth_access_token}': options.authorization.access_token,
|
||||
|
@ -230,7 +243,7 @@ module.exports.getLaunchOptions = function (version, forge, options) {
|
|||
'${version_name}': options.version.number,
|
||||
'${assets_index_name}': version.assetIndex.id,
|
||||
'${game_directory}': path.join(options.root),
|
||||
'${assets_root}': path.join(options.root, 'assets'),
|
||||
'${assets_root}': assetPath,
|
||||
'${version_type}': options.version.type
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "minecraft-launcher-core",
|
||||
"version": "2.3.1",
|
||||
"version": "2.4.0",
|
||||
"description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
|
|
Loading…
Add table
Reference in a new issue