Hi, I have some recipe types that replaceInput doesn't work on. I'm trying to make my own function to imitate it. Although I know how to get the contents of a JSON recipe object, I'm not sure how to set them. In their definition, they look like theyre the immutable JsonObject. I could build a new one as a copy in Java, but I'm not sure how to do so in JavaScript.
https://docs.oracle.com/javaee/7/api/javax/json/JsonObject.html
https://github1s.com/KubeJS-Mods/KubeJS/blob/2001/common/src/main/java/dev/latvian/mods/kubejs/recipe/RecipeJS.java#L60
When printed to console, they appear to have type HashMap. But neither JavaScript's set or Java's put seem to work.
Here's the code I'm working with:
let replaceWithTag = (item, tag, recipetype) => {
event.forEachRecipe( {type: recipetype, input: item}, r => {
let ingredients = r.json.get("ingredients")
let newIngredients = Array()
console.log(r.json)
for (const ingredient of ingredients) {
if (ingredient.get("item") == item ) {
ingredient.delete("item")
ingredient.set("tag", tag)
}
newIngredients.push(ingredient)
}
r.json.set("ingredients", newIngredients) // doesn't work
})
}```
