Adding in support for older MC versions. Looking into sound issue

This commit is contained in:
Pierce 2019-03-26 12:20:36 -04:00
parent 8e3d6751ae
commit b21ddf1d63
3 changed files with 17 additions and 5 deletions

View file

@ -1,5 +1,4 @@
# Minecraft Launcher Core # 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. 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. Basically a core for your Electron or script based launchers.

View file

@ -81,6 +81,7 @@ module.exports.getAssets = function (directory, version) {
return new Promise(async(resolve) => { return new Promise(async(resolve) => {
const assetsUrl = 'https://resources.download.minecraft.net'; const assetsUrl = 'https://resources.download.minecraft.net';
const failed = []; const failed = [];
const parseVersion = version.assetIndex.id.split('.');
if(!fs.existsSync(path.join(directory, 'assets', 'indexes', `${version.assetIndex.id}.json`))) { 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`); 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); const download = await downloadAsync(`${assetsUrl}/${subhash}/${hash}`, assetDirectory, hash);
if(download.failed) failed.push(download.asset); 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) { module.exports.getLaunchOptions = function (version, forge, options) {
return new Promise(resolve => { return new Promise(resolve => {
let type = forge || version; const parseVersion = version.assetIndex.id.split('.');
let arguments = type.minecraftArguments ? type.minecraftArguments.split(' ') : type.arguments.game; 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 = { const fields = {
'${auth_access_token}': options.authorization.access_token, '${auth_access_token}': options.authorization.access_token,
@ -230,7 +243,7 @@ module.exports.getLaunchOptions = function (version, forge, options) {
'${version_name}': options.version.number, '${version_name}': options.version.number,
'${assets_index_name}': version.assetIndex.id, '${assets_index_name}': version.assetIndex.id,
'${game_directory}': path.join(options.root), '${game_directory}': path.join(options.root),
'${assets_root}': path.join(options.root, 'assets'), '${assets_root}': assetPath,
'${version_type}': options.version.type '${version_type}': options.version.type
}; };

View file

@ -1,6 +1,6 @@
{ {
"name": "minecraft-launcher-core", "name": "minecraft-launcher-core",
"version": "2.3.1", "version": "2.4.0",
"description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge", "description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge",
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {