i am immortal nothing can stop me

This commit is contained in:
2vb 2023-11-21 03:19:54 -08:00
parent d2bbe6f225
commit 9d3fba6072
2 changed files with 84 additions and 38 deletions

View File

@ -9,7 +9,6 @@
}, },
"rules": { "rules": {
"arrow-spacing": ["warn", { "before": true, "after": true }], "arrow-spacing": ["warn", { "before": true, "after": true }],
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
"comma-dangle": ["error", "always-multiline"], "comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error", "comma-spacing": "error",
"comma-style": "error", "comma-style": "error",

121
index.js
View File

@ -1,63 +1,110 @@
const decompress = require('decompress'); const decompress = require('decompress');
const fs = require('fs'); const fs = require('fs');
const jsonfile = require('jsonfile'); const jsonfile = require('jsonfile');
const file = 'blocks.json'; // const file = 'blocks.json';
const blockRemaps = 'blocks.json';
let blocks; let blocks;
jsonfile.readFile(file, function (err, obj) { jsonfile.readFile(blockRemaps, function (err, obj) {
if (err) console.error(err); if (err) console.error(err);
blocks = obj; blocks = obj;
}); });
const itemRemaps = 'items.json';
let items;
jsonfile.readFile(itemRemaps, function (err, obj) {
if (err) console.error(err);
items = obj;
});
/*
Textures to check in the future:
- Clock
- Compass
- Filled Map
- Potion
*/
extract('1.8'); extract('1.8');
// extract("1.20.1") // extract("1.20.1")
// TODO (maybe): clock and compass textures
function extract(string) { function extract(string) {
const extractedPath = 'out/assets/minecraft/textures/'; const extractedPath = `out/${string}/assets/minecraft/textures/`;
decompress(`test/${string}.zip`, 'out/').then(files => { decompress(`test/${string}.zip`, `out/${string}`).then(files => {
files.forEach(element => { files.forEach(element => {
if (!element.path.includes('assets/minecraft/textures/')) { if (!element.path.includes('assets/minecraft/textures/')) {
return; return;
} }
const texture = element.path.match(/(?:[A-Za-z]*\/)*([A-Za-z]*)\/([A-Za-z_0-9]*)\.(png\.mcmeta|png)/); // const texture = element.path.match(/(?:[A-Za-z]*\/)*([A-Za-z]*)\/([A-Za-z_0-9]*)\.(png\.mcmeta|png)/);
/* const texture = element.path.match(/([A-Za-z]*)\/([A-Za-z]*)\/([A-Za-z_0-9]*)\.(png\.mcmeta|png)/);
[ if (!texture) return;
'assets/minecraft/textures/misc/vignette.png.mcmeta', let type = texture[1];
'misc', const subtype = texture[2];
'vignette', const name = texture[3];
'png.mcmeta', const extension = texture[4];
index: 0, let rename;
input: 'assets/minecraft/textures/misc/vignette.png.mcmeta', if (type == 'textures') {
groups: undefined type = subtype;
] }
*/ if (type == 'items') {
if (texture) { rename = items[name];
// const path = texture[0]; }
const type = texture[1]; if (type == 'blocks') {
const name = texture[2]; rename = blocks[name];
const extension = texture[3]; }
const rename = blocks[name]; const path1 = `${extractedPath}${type}/`;
const poggers = `${extractedPath}${type}/`; // if (type == 'items') {
if (type == 'blocks' && rename) { // rename == items;
try { // }
fs.renameSync(`${poggers}${name}.${extension}`, `${poggers}${rename}.${extension}`); // if (type == 'blocks') {
console.log(`Renamed ${poggers}${name}.${extension} to ${poggers}${rename}.${extension}`); // rename == blocks;
} // }
catch (err) { if (rename) {
console.log(err); try {
} fs.renameSync(`${path1}${name}.${extension}`, `${path1}${rename}.${extension}`);
console.log(`Renamed ${path1}${name}.${extension} to ${path1}${rename}.${extension}`);
} catch (error) {
console.log(error);
// console.log(`(type ${type}\nsubtype ${subtype}\nname ${name}\nextension ${extension})`);
} }
} }
// const path = texture[0];
// const type = texture[1];
// const name = texture[2];
// const extension = texture[3];
// const rename = blocks[name];
// const poggers = `${extractedPath}${type}/`;
// if (rename) {
// try {
// // fs.renameSync(`${poggers}${name}.${extension}`, `${poggers}${rename}.${extension}`);
// // console.log(`Renamed ${poggers}${name}.${extension} to ${poggers}${rename}.${extension}`);
// }
// catch (err) {
// console.log(err);
// }
// }
// console.log(texture);
}); });
}).then(() => { }).then(() => {
fs.renameSync(`${extractedPath}blocks`, `${extractedPath}block`); try {
jsonfile.readFile('out/pack.mcmeta', function (err, obj) { fs.renameSync(`${extractedPath}blocks`, `${extractedPath}block`);
console.log(`Renamed ${extractedPath}blocks to ${extractedPath}block`);
} catch (error) {
console.log(error);
}
try {
fs.renameSync(`${extractedPath}items`, `${extractedPath}item`);
console.log(`Renamed ${extractedPath}items to ${extractedPath}item`);
} catch (error) {
console.log(error);
}
jsonfile.readFile(`out/${string}/pack.mcmeta`, function (err, obj) {
if (err) console.error(err); if (err) console.error(err);
const oldFormat = obj.pack.pack_format; const oldFormat = obj.pack.pack_format;
obj.pack.pack_format = 15; const newFormat = 15;
jsonfile.writeFile('out/pack.mcmeta', obj, { spaces: 2 }, function (err) { obj.pack.pack_format = newFormat;
jsonfile.writeFile(`out/${string}/pack.mcmeta`, obj, { spaces: 2 }, function (err) {
if (err) console.error(err); if (err) console.error(err);
console.log(`${oldFormat} changed to 15`); console.log(`Pack format changed from ${oldFormat} to ${newFormat}`);
}); });
}); });
}); });