UnifyTags

UnifyTags

3.2k Downloads

Recipe Output tag support

Xeloboyo opened this issue ยท 1 comments

commented

The script does not seem to modify recipes whose outputs are already tags to the 'priority' item of the tag.
For now I'm using this workaround for immersive engineering. Any official support would be much appreciated.

for (let [tag, stacks] of Object.entries(global["tagItems"])) {
        let priorityId = global["tagPriorityItems"][tag]
        for (let itemId of stacks) {
            if (global["unifyexclude"].has(itemId)) continue

            // Replace any time the item appears as an input, with the whole tag
            event.replaceInput({}, itemId, "#" + tag)
            // Replace any time the item appears as an output, with the priority item
            // (Unless this is the priority item itself, then do nothing)
            if (itemId != priorityId) event.replaceOutput({}, itemId, priorityId)
        }
       /// workaround
	event.forEachRecipe({type: /immersiveengineering:.*/}, (r) => {
		let result = r.json.get("results");
		if(result.has("base_ingredient")){
			if(result.get("base_ingredient").get("tag") == tag){
				var amount = parseInt(result.get("count"));
				r.json.remove("results");
				r.json.add("results", {
					item: priorityId,
					count: amount
				});
				r.save();
			}
		}else{
			if(result.get("tag") == tag){
				r.json.remove("results");
				r.json.add("results", {
					item: priorityId,
					count: 1
				});
				r.save();
			}
		}
	});
....
		
commented

This line:

if (itemId != priorityId) event.replaceOutput({}, itemId, priorityId)

Theoretically should replace the output in every recipe which is an item that is not a priority. If that does not happen in every case, then this is likely a result of immersive engineering not supporting the event.replaceOutput() format. I did not, however, know that you could modify the json of recipes directly. Perhaps support for other mods could be done in the future.

For now though, I will not be fixing the recipes of every single mod that does not work with event.replaceOutput(). Feel free to keep using your workaround though, and modify the script at your own whim.