diff --git a/index.js b/index.js index ee1836e..a00a629 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,19 @@ const decompress = require('decompress'); const fs = require('fs'); +const jsonfile = require('jsonfile') +const file = 'blocks.json' +let blocks; +jsonfile.readFile(file, function (err, obj) { + if (err) console.error(err) + // console.dir(obj) + blocks = obj; +}) extract("1.8") // extract("1.20.1") function extract(string) { decompress(`test/${string}.zip`, `out/${string}`).then(files => { - console.log("extracted") // try { // fs.renameSync(`out/${string}/assets/minecraft/textures/blocks`, `out/${string}/assets/minecraft/textures/block`) // fs.renameSync(`out/${string}/assets/minecraft/textures/items`, `out/${string}/assets/minecraft/textures/item`) @@ -14,8 +21,13 @@ function extract(string) { // console.log(error); // } files.forEach(element => { - // console.log(`Extracted ${element.path} from ${string}.zip`) - console.log(files) + if (!element.path.includes("assets/minecraft/textures/")) { + return; + } + let texture = element.path.match(/(?:[A-Za-z]*\/)*([A-za-z]*)\/([A-Za-z_]*).png/); + // let type = texture[0] + // let name = texture[1] + console.log(texture) }) }) } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3d9c5e0..d11c2bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "decompress": "^4.2.1" + "decompress": "^4.2.1", + "jsonfile": "^6.1.0" } }, "node_modules/base64-js": { @@ -277,6 +278,17 @@ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, "node_modules/make-dir": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", @@ -456,6 +468,14 @@ "through": "^2.3.8" } }, + "node_modules/universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 9ccd801..6d42220 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,13 @@ "description": "L vipermc", "main": "index.js", "scripts": { - "start": "rm -r out && mkdir out && node index.js" + "start": "rm -r out && mkdir out && node index.js", + "test": "clear && npm start" }, "author": "", "license": "ISC", "dependencies": { - "decompress": "^4.2.1" + "decompress": "^4.2.1", + "jsonfile": "^6.1.0" } }