Compare commits
No commits in common. "main" and "1.21-pre2" have entirely different histories.
3
.gitignore
vendored
3
.gitignore
vendored
@ -132,5 +132,4 @@ dist
|
||||
|
||||
# MSE chicanery
|
||||
Maoist-Standard-English.zip
|
||||
template/assets/minecraft/lang/en_mse.json
|
||||
resourcepacks
|
||||
template/assets/minecraft/lang/en_mse.json
|
19
README.md
19
README.md
@ -9,9 +9,7 @@
|
||||
```
|
||||
|
||||
Example usage:
|
||||
|
||||
* `./packgen.js -fR` generate a pack with the latest release version and descriptive output (recommended)
|
||||
* `./packgen.js -f -v 1.15` using version "1.15" for pack generation
|
||||
|
||||
* `./packgen.js --lang en_nz` generate a pack using `en_nz` insead of the default `en_gb`
|
||||
* `./packgen.js -f` generate a pack with a descriptive output zip E.g. `en_gb-v1.19.1-en_MSE` insead of just `Maoist-Standard-English.zip`
|
||||
* `./packgen.js -m https://example.com/mc/game/version_manifest_v2.json -r https://example.com/` with a custom server `example.com`
|
||||
@ -170,15 +168,12 @@ zlm_arab
|
||||
## General Options:
|
||||
```
|
||||
Options:
|
||||
-h, --help Show help [boolean]
|
||||
-V, --version Show version number [boolean]
|
||||
-f, --descriptivefile descriptive output E.g. "en_gb-v1.19.1-en_MSE"[boolean]
|
||||
-l, --lang <language> base language for pack generation [string]
|
||||
-v, --verid <version-id> base version for pack generation [string]
|
||||
-R, --releaseOnly use only the *latest* release version [boolean]
|
||||
-m, --manifest <url> custom manifest endpoint [string]
|
||||
-r, --resources <url> custom resources endpoint [string]
|
||||
-d, --debug verbose debug output [boolean]
|
||||
-h, --help Show help [boolean]
|
||||
-V, --version Show version number [boolean]
|
||||
-f, --descriptivefile Descriptive output E.g. "en_gb-v1.19.1-en_MSE" [boolean]
|
||||
-l, --lang <language> base language for pack generation [string]
|
||||
-m, --manifest <url> custom manifest endpoint [string]
|
||||
-r, --resources <url> custom resources endpoint [string]
|
||||
```
|
||||
|
||||
# Why Us
|
||||
|
16
packall.sh
16
packall.sh
@ -1,8 +1,8 @@
|
||||
./packgen.js -fR -l en_au
|
||||
./packgen.js -fR -l en_ca
|
||||
./packgen.js -fR -l en_gb
|
||||
./packgen.js -fR -l en_nz
|
||||
./packgen.js -fR -l en_pt
|
||||
./packgen.js -fR -l en_ud
|
||||
./packgen.js -fR -l enp
|
||||
./packgen.js -fR -l enws
|
||||
./packgen.js -f -l en_au
|
||||
./packgen.js -f -l en_ca
|
||||
./packgen.js -f -l en_gb
|
||||
./packgen.js -f -l en_nz
|
||||
./packgen.js -f -l en_pt
|
||||
./packgen.js -f -l en_ud
|
||||
./packgen.js -f -l enp
|
||||
./packgen.js -f -l enws
|
66
packgen.js
66
packgen.js
@ -25,20 +25,13 @@ var argv = require("yargs/yargs")(process.argv.slice(2))
|
||||
required: false,
|
||||
type: "string",
|
||||
},
|
||||
verid: {
|
||||
alias: "v",
|
||||
description: "<version-id> base version for pack generation",
|
||||
requiresArg: true,
|
||||
required: false,
|
||||
type: "string",
|
||||
},
|
||||
releaseOnly: {
|
||||
alias: "R",
|
||||
description: "use only the *latest* release version",
|
||||
requiresArg: false,
|
||||
required: false,
|
||||
type: "boolean",
|
||||
},
|
||||
// TODO: version: {
|
||||
// alias: "v",
|
||||
// description: "<version> base version for pack generation",
|
||||
// requiresArg: true,
|
||||
// required: false,
|
||||
// type: "string",
|
||||
// },
|
||||
manifest: {
|
||||
alias: "m",
|
||||
description: "<url> custom manifest endpoint",
|
||||
@ -53,22 +46,9 @@ var argv = require("yargs/yargs")(process.argv.slice(2))
|
||||
required: false,
|
||||
type: "string",
|
||||
},
|
||||
debug: {
|
||||
alias: "d",
|
||||
description: "verbose debug output",
|
||||
requiresArg: false,
|
||||
required: false,
|
||||
type: "boolean",
|
||||
},
|
||||
})
|
||||
.parse();
|
||||
|
||||
if (argv.debug) {console.log(argv)}
|
||||
if (argv.verid && argv.releaseOnly) {
|
||||
console.log('Ignoreing specified version and using latest release. (remove "releaseOnly" to use specified version)')
|
||||
argv.verid = undefined
|
||||
}
|
||||
|
||||
const urlReq = function (reqUrl, options, cb) {
|
||||
if (typeof options === "function") {
|
||||
cb = options;
|
||||
@ -99,22 +79,7 @@ let piston =
|
||||
|
||||
urlReq(piston, function (body, res) {
|
||||
json = JSON.parse(body);
|
||||
var version;
|
||||
|
||||
if (argv.releaseOnly) {
|
||||
version = json.versions.filter(v => v.type === 'release')[0].id // latest type ("release") version
|
||||
} else if (argv.verid) {
|
||||
if (json.versions.filter(v => v.id === argv.verid ).length >= 1) { // specified ("argv.verid") version
|
||||
console.log("Found metadata for",argv.verid)
|
||||
version = argv.verid
|
||||
} else {
|
||||
console.log("No metadata found for",argv.verid,"are you sure this is a valid version id?")
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
version = json.versions[0].id; // latest type ("any") version
|
||||
}
|
||||
|
||||
let version = json.versions[0].id; // latest version
|
||||
let resources =
|
||||
argv.resources || "https://resources.download.minecraft.net/";
|
||||
let baselang = argv.lang || "en_gb";
|
||||
@ -134,16 +99,10 @@ urlReq(piston, function (body, res) {
|
||||
|
||||
console.log(`Using base language "${baselang}" from version (${version})`);
|
||||
|
||||
if (argv.debug) {console.log(version,json.versions.filter(v => v.id === version )[0].url)}
|
||||
|
||||
urlReq(json.versions.filter(v => v.id === version )[0].url, function (body, res) {
|
||||
urlReq(json.versions[1].url, function (body, res) {
|
||||
json = JSON.parse(body);
|
||||
urlReq(json.assetIndex.url, function (body, res) {
|
||||
json = JSON.parse(body);
|
||||
if (json.objects[`minecraft/lang/${baselang}.json`] === undefined) {
|
||||
console.log("This version has no/outdated language file (only ≥1.13 )")
|
||||
process.exit(1);
|
||||
}
|
||||
hash = json.objects[`minecraft/lang/${baselang}.json`].hash;
|
||||
urlReq(
|
||||
resources + `${hash.substring(0, 2)}/${hash}`,
|
||||
@ -173,7 +132,6 @@ urlReq(piston, function (body, res) {
|
||||
|
||||
var mcmeta = __dirname + "/template/pack.mcmeta";
|
||||
var mcmeta_data = JSON.parse(fs.readFileSync(mcmeta));
|
||||
var mcmeta_data_old = fs.readFileSync(mcmeta);
|
||||
mcmeta_data.pack.description = mcmeta_template;
|
||||
|
||||
fs.writeFileSync(mcmeta, JSON.stringify(mcmeta_data));
|
||||
@ -187,10 +145,8 @@ urlReq(piston, function (body, res) {
|
||||
console.log(
|
||||
"en_mse.json generated, creating pack and compressing.",
|
||||
);
|
||||
// Make sure resourcepacks folder exists
|
||||
if (!fs.existsSync(__dirname +"/resourcepacks/")) {fs.mkdirSync(__dirname +"/resourcepacks/")}
|
||||
const output = fs.createWriteStream(
|
||||
__dirname + `/resourcepacks/${filename}.zip`,
|
||||
__dirname + `/${filename}.zip`,
|
||||
);
|
||||
const archive = archiver("zip", {
|
||||
zlib: { level: 9 }, // Sets the compression level.
|
||||
@ -203,7 +159,7 @@ urlReq(piston, function (body, res) {
|
||||
"language-pack archive generated with a filesize of " +
|
||||
archive.pointer() +
|
||||
" bytes" +
|
||||
`\n(./resourcepacks/${filename}.zip)`,
|
||||
`\n(./${filename}.zip)`,
|
||||
);
|
||||
});
|
||||
archive.pipe(output);
|
||||
|
Loading…
Reference in New Issue
Block a user