Last active
March 12, 2025 22:51
-
-
Save shanoaice/33627e87a05169a168fedda826f2dfec to your computer and use it in GitHub Desktop.
Generate Thermal Expansion's Insulator Machine Recipes for Mystical Agriculture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { opendir, mkdir, writeFile } from "node:fs/promises"; | |
import path from "node:path"; | |
// usage: put this script under the root folder of MysticalAgriculture project source and run it using Node.js v18 | |
// generated recipes will be under `thermal_integration/recipes` folder. | |
function generateInsolatorRecipe(name) { | |
const potentialEmptyTags = ["silicon", "rubber"]; | |
const potentialEmptyIngotTags = [ | |
"uranium", | |
"aluminum", | |
"iridium", | |
"mithril", | |
"platinum", | |
"titanium", | |
"chrome", | |
"tungsten", | |
"graphite", | |
"zinc", | |
"brass", | |
]; | |
const recipe = { | |
type: "thermal:insolator", | |
ingredient: { | |
item: `mysticalagriculture:${name}_seeds`, | |
}, | |
result: [ | |
{ | |
item: `mysticalagriculture:${name}_essence`, | |
count: 1, | |
}, | |
{ | |
item: `mysticalagriculture:${name}_seeds`, | |
count: 1, | |
}, | |
], | |
energy: 100000, | |
conditions: [ | |
{ | |
type: "forge:mod_loaded", | |
modid: "mysticalagriculture", | |
}, | |
{ | |
type: "mysticalagriculture:crop_has_material", | |
crop: `mysticalagriculture:${name}`, | |
}, | |
], | |
}; | |
if (potentialEmptyTags.indexOf(name) !== -1) { | |
recipe.conditions.push({ | |
type: "forge:not", | |
value: { type: "forge:tag_empty", tag: `forge:${name}` }, | |
}); | |
} | |
if (potentialEmptyIngotTags.indexOf(name) !== -1) { | |
recipe.conditions.push({ | |
type: "forge:not", | |
value: { type: "forge:tag_empty", tag: `forge:ingots/${name}` }, | |
}); | |
} | |
return recipe; | |
} | |
const mysticalag = await opendir( | |
"src/generated/resources/data/mysticalagriculture/recipes/seed/crafting", | |
); | |
const recipesList = new Map(); | |
for await (const entries of mysticalag) { | |
if (entries.isFile()) { | |
const name = entries.name.split(".")[0]; | |
recipesList.set( | |
`insolator_mysticalag_${name}_seeds`, | |
generateInsolatorRecipe(name), | |
); | |
} | |
} | |
await mkdir(path.join("thermal_integration/recipes"), { recursive: true }); | |
await Promise.all( | |
Array.from(recipesList, (entries) => | |
writeFile( | |
path.join("thermal_integration/recipes", `${entries[0]}.json`), | |
JSON.stringify(entries[1], null, 4), | |
), | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment