feat: filter script

This commit is contained in:
trafficlunar 2024-12-21 15:57:07 +00:00
parent f63abc4ee9
commit bd876eb5c3
2 changed files with 120 additions and 0 deletions

33
generator/filter.js Normal file
View file

@ -0,0 +1,33 @@
const fs = require("fs");
const path = require("path");
const regex = require("./regex.json");
const INPUT = path.join(__dirname, "blocks/");
function isBlacklisted(fileName) {
if (!fileName.endsWith(".png")) return true;
return regex.some((pattern) => {
const regex = new RegExp(pattern);
return regex.test(fileName);
});
}
fs.readdir(INPUT, (err, files) => {
if (err) throw err;
files.forEach((file) => {
const filePath = path.join(INPUT, file);
if (isBlacklisted(file)) {
fs.unlink(filePath, (err) => {
if (err) {
console.error(`Error deleting file ${file}:`, err);
} else {
console.log(`Deleted file: ${file}`);
}
});
}
});
});

87
generator/regex.json Normal file
View file

@ -0,0 +1,87 @@
[
"NOTE: AN AI GENERATED THIS",
"glass_pane_top",
".*tulip.*",
".*water.*",
".*vine.*",
".*turtle_egg.*",
"(?!.*block.*)block",
".*tripwire.*",
".*torch.*",
"tnt_(top|bottom)",
"sea_pickle",
".*seagrass.*",
"tall_grass",
".*flower.*",
".*sugar_cane.*",
"structure_block_.*",
"stone_slab_top",
".*sapling.*",
".*leaves.*",
".*_door.*",
"sandstone_(top|bottom)",
".*bush.*",
"(?!command_block_front).*command_block(?!(_front|_repeating|_chain))",
".*repeater.*",
"(?<=_)on(?=.*)",
".*dust.*",
"red_mushroom",
".*rail.*",
"quartz_(pillar_top|block_(top|bottom))",
"purpur_pillar_top",
"pumpkin_top",
".*stem.*",
".*stage.*",
".*poppy.*",
"(?!piston_top).*piston.*",
".*peony.*",
".*daisy.*",
"observer_top",
".*portal.*",
"mycelium_top",
"lily_pad",
".*lilac.*",
".*lever.*",
".*lava.*",
".*fern.*",
".*ladder.*",
"jukebox_top",
"iron_bars",
".*hopper.*",
"grass_block_top",
"^(?!.*grass_block).*grass.*",
"grass_block_side_overlay",
"furnace_top",
"frosted_ice_0",
".*fire.*",
".*farmland.*",
".*end_rod.*",
".*end_portal_frame.*",
".*enchanting_table.*",
"dropper_front_vertical",
"dragon_egg",
"dispenser_front_vertical",
".*debug.*",
".*daylight_detector.*",
".*dandelion.*",
".*anvil.*",
"(?!crafting_table_front).*crafting_table.*",
".*conduit.*",
".*comparator.*",
".*chorus_(plant|flower).*",
"chiseled_quartz_block_top",
"(?!cauldron_side).*cauldron.*",
".*cake.*",
".*cactus.*",
"brown_mushroom",
".*brewing_stand.*",
".*orchid.*",
".*allium.*",
".*azure.*",
".*beacon.*",
"^(?!.*coral_block).*coral.*",
"^(?!.*dried_kelp_side).*kelp.*",
"podzol_top",
"frosted_ice",
"iron_trapdoor"
]