CyclopsMC / IntegratedCrafting

Craft stuff in Integrated Dynamics networks
MIT License
7 stars 6 forks source link

Add a predicate to the crafting writer #76

Open Corfiot opened 2 years ago

Corfiot commented 2 years ago

Issue type:


Short description:

I want to be able to create a predicate, for example "Do I have less than X items in machine's Y slot Z?" and put that in the crafting writer for the item in question. Then the writer would craft if the result is predicate is true.

Concrete example: craft enriched redstone items for mekanism's infusing factories, I read the infusion level from the machine via NBT and want to only craft when that is not full.

There are workarounds but I don't like them.

rubensworks commented 2 years ago

Thanks for the suggestion!

rubensworks commented 2 years ago

So this would accept an operator that takes no inputs and returns an ingredient/recipe if I understand correctly?

Corfiot commented 2 years ago

A valid question, I guess it could return a recipe but that, IMHO, would be a separate feature, to be implemented after & in addition to this one.

In my original thought it was a predicate returning boolean. True=keep crafting, false=stop crafting. I would expect not to break the pattern in the other components, e.g. the filtering item interface, which auto-populates stuff like Item/uname/name.

The predicate would probably use the writer's recipe as input, from which anything needed to make a decision can be extracted. In the example I gave, it would take the infusion item created from the output ingredients, count its amount in the machine, then return lessthan(#items_in_network,#desiredamounttohave*const_infusionamountperitemproduced).

Yes it would be complicated but not much more than the items-in-chest-by-mod tutorial.