Fixed downloads causing crashes. Better Docs

This commit is contained in:
Pierce 2019-02-10 21:21:14 -05:00
parent 9574095696
commit 2652654c18
3 changed files with 17 additions and 15 deletions

View file

@ -1,8 +1,8 @@
# Minecraft Launcher Core
### Currently only supports MC 1.7.3 and up.
A script that launches Minecraft using NodeJS.
Supports Vanilla and Forge.
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.
### Installing
@ -10,7 +10,6 @@ Supports Vanilla and Forge.
### Usage
##### launcher.core Options
| Parameter | Type | Description | Required |
@ -49,14 +48,15 @@ Supports Vanilla and Forge.
#### Events
| Event Name | Type | Description |
|-------------------|---------|-------------------------------------------------------------------------------------|
| `data` | Buffer | Emitted when information is returned from the Minecraft Process |
| `close` | Integer | Code number that is returned by the Minecraft Process |
| `error` | String | Emitted when the Minecraft Process errors |
| `package-extract` | null | Emitted when `clientPackage` finishes being extracted |
| Event Name | Type | Description |
|-------------------|---------|---------------------------------------------------------------------------------------|
| `data` | Buffer | Emitted when information is returned from the Minecraft Process |
| `close` | Integer | Code number that is returned by the Minecraft Process |
| `error` | String | Emitted when the Minecraft Process errors |
| `package-extract` | null | Emitted when `clientPackage` finishes being extracted |
| `start` | null | Emitted after `launchArguments` are set. THIS WILL BE DEPRECATED AS ITS NOT ACCURATE |
| `download` | String | Emitted when a file successfully downloads |
| `download-status` | Object | Emitted when data is received while downloading |
#### Client Package Function
Client Packages allow the client to run offline on setup. This function should be used outside the actual launcher.
@ -69,7 +69,6 @@ this function is in the `handler` component.
| `versions` | Array | Array of the versions being downloaded and being made into a package. | True |
| `os` | String | OS that the package will be loaded on. OS specific natives need this. | True |
### Examples
```javascript
const launcher = require('minecraft-launcher-core');

View file

@ -25,8 +25,11 @@ function downloadAsync (url, directory, name) {
});
_request.on('data', (data) => {
let size = 0;
if(fs.existsSync(path.join(directory, name))) size = fs.statSync(path.join(directory, name))["size"];
event.emit('download-status', {
"current": Math.round(fs.statSync(path.join(directory, name))["size"] / 10000),
"name": name,
"current": Math.round(size / 10000),
"total": data.length
})
});
@ -35,7 +38,7 @@ function downloadAsync (url, directory, name) {
_request.pipe(file);
file.once('finish', function() {
console.log("Downloaded: " + name);
event.emit('download', name);
resolve({failed: false, asset: null});
});
});
@ -289,4 +292,4 @@ module.exports.extractPackage = function(root, clientPackage) {
event.emit('package-extract', true);
resolve();
});
};
};

View file

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