poggers commit fixing everything! :3

This commit is contained in:
2vb 2023-11-20 22:33:12 -08:00
parent cda730b704
commit b5d888f10b
5 changed files with 1193 additions and 58 deletions

44
.eslintrc.json Normal file
View File

@ -0,0 +1,44 @@
{
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2021
},
"rules": {
"arrow-spacing": ["warn", { "before": true, "after": true }],
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
"curly": ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"handle-callback-err": "off",
"indent": ["error", "tab"],
"keyword-spacing": "error",
"max-nested-callbacks": ["error", { "max": 4 }],
"max-statements-per-line": ["error", { "max": 2 }],
"no-console": "off",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
"no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
"no-trailing-spaces": ["error"],
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
"quotes": ["error", "single"],
"semi": ["error", "always"],
"space-before-blocks": "error",
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"yoda": "error"
}
}

View File

@ -175,7 +175,7 @@
"red_sandstone_carved":"chiseled_red_sandstone",
"red_sandstone_normal":"red_sandstone",
"red_sandstone_smooth":"cut_red_sandstone",
"redstone_dust_line":"redstone_dust_line0.png",
"redstone_dust_line":"redstone_dust_line0",
"redstone_lamp_off":"redstone_lamp",
"redstone_torch_on":"redstone_torch",
"reeds":"sugar_cane",

101
index.js
View File

@ -1,67 +1,54 @@
const decompress = require('decompress');
const fs = require('fs');
const jsonfile = require('jsonfile')
const file = 'blocks.json'
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;
})
if (err) console.error(err);
// console.dir(obj)
blocks = obj;
});
extract("1.8")
extract('1.8');
// extract("1.20.1")
function extract(string) {
const extractedPath = `out/assets/minecraft/textures/`
decompress(`test/${string}.zip`, `out/`).then(files => {
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`)
// fs.renameSync(`out/assets/minecraft/textures/blocks`, `out/assets/minecraft/textures/block`)
// fs.renameSync(`out/assets/minecraft/textures/items`, `out/assets/minecraft/textures/item`)
} catch (error) {
console.log(error);
}
files.forEach(element => {
if (!element.path.includes("assets/minecraft/textures/")) {
return;
}
let texture = element.path.match(/(?:[A-Za-z]*\/)*([A-za-z]*)\/([A-Za-z_]*).png/);
// console.log(files)
// console.log(texture)
/*
[
'assets/minecraft/textures/particle/particles.png', [0] (path)
'particle', [1] (group)
'particles', [2] (name)
index: 0, [3]
input: 'assets/minecraft/textures/particle/particles.png', [4]
groups: undefined [5]
]
*/
if (texture) {
let path = texture[0]
let group = texture[1]
let name = texture[2]
let rename = blocks[name]
const poggers = `${extractedPath}${group}/`
// console.log(texture)
// console.log(type)
if (group == "blocks" && rename) {
// console.log(rename)
try {
// TODO: fix trying to rename file twice because of png.mcmeta
fs.renameSync(`${poggers}${name}.png`, `${poggers}${rename}.png`)
console.log(`renamed ${poggers}${rename}`)
// fs.existsSync(poggers)
// console.log(poggers)
} catch (error) {
console.log(error)
}
}
}
})
})
const extractedPath = 'out/assets/minecraft/textures/';
decompress(`test/${string}.zip`, 'out/').then(files => {
files.forEach(element => {
if (!element.path.includes('assets/minecraft/textures/')) {
return;
}
const texture = element.path.match(/(?:[A-Za-z]*\/)*([A-Za-z]*)\/([A-Za-z_0-9]*)\.(png\.mcmeta|png)/);
/*
[
'assets/minecraft/textures/misc/vignette.png.mcmeta',
'misc',
'vignette',
'png.mcmeta',
index: 0,
input: 'assets/minecraft/textures/misc/vignette.png.mcmeta',
groups: undefined
]
*/
if (texture) {
// 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 (type == 'blocks' && 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);
}
}
}
});
});
}

1101
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,5 +12,8 @@
"dependencies": {
"decompress": "^4.2.1",
"jsonfile": "^6.1.0"
},
"devDependencies": {
"eslint": "^8.54.0"
}
}