mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-08-12 12:29:42 +00:00
fix: bunch of block data fixes
This commit is contained in:
parent
6883267b95
commit
a953914bd3
7 changed files with 207 additions and 79 deletions
45
generator/scripts/fix.js
Normal file
45
generator/scripts/fix.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const sharp = require("sharp");
|
||||
|
||||
const INPUT = path.join(__dirname, "../blocks/");
|
||||
|
||||
(async () => {
|
||||
const files = fs.readdirSync(INPUT);
|
||||
|
||||
for (const file of files) {
|
||||
const filePath = path.join(INPUT, file);
|
||||
const image = sharp(filePath);
|
||||
const metadata = await image.metadata();
|
||||
|
||||
if (file.includes("glazed")) {
|
||||
await image
|
||||
.rotate(90)
|
||||
.toBuffer()
|
||||
.then((buffer) => {
|
||||
fs.writeFileSync(filePath, buffer);
|
||||
});
|
||||
}
|
||||
|
||||
if (file.includes("barrel_top")) {
|
||||
await image
|
||||
.rotate(180)
|
||||
.toBuffer()
|
||||
.then((buffer) => {
|
||||
fs.writeFileSync(filePath, buffer);
|
||||
});
|
||||
}
|
||||
|
||||
if (metadata.height > 16) {
|
||||
await image
|
||||
.extract({ top: 0, left: 0, width: 16, height: 16 })
|
||||
.resize(16, 16)
|
||||
.toBuffer()
|
||||
.then((buffer) => {
|
||||
fs.writeFileSync(filePath, buffer);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Done!");
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue