Hello, I am trying to generate dynamically custom function. For better understanding of my achievement, please look below on this code with further explanation.
/**
* @param {'modid:item'} input
* @param {'modid:item'} optional_input
*
* @param {'modid:item'} output
* @param {'modid:item'} optional_output
*
* @param {number} xp
* @param {number} cooktime
*/
onEvent('recipes', event => {
function UNSUPPORTED_MOD_MACHINE(input, optional_input1, output, optional_output, xp, cooktime) {
event.custom({
"type": "unsupported_mod_machine:crunch",
"ingredient": {
"item": input,
"item": optional_input
},
"result": {
"item": output,
"item": optional_output
},
"experience": xp,
"cookingtime": cooktime
}
]
})
}
UNSUPPORTED_MOD_MACHINE("minecraft:paprika", optional_input, "minecraft:piggybank", optional_output, 100, 200)
})
Hope this helps to clarify things a bit more.
Resulting behavior should be that if I do not put there optional_x, recipe just loads without it but if I write there some additional ingredients, it gets registered properly.


