Applied Energistics 2

Applied Energistics 2

137M Downloads

Max Autocrafting

Zephreo opened this issue · 3 comments

commented

Describe the feature

When you autocraft an item during the select amount screen there should be an additional button max which sets the amount to the maximum you can craft given the ingredients in the me system.

Reasons why it should be considered

It will help with automation and crafting of things that are required in arbitrary amounts, I often spend a lot of time checking just how many 64k drives I can actually craft with the amount of resources I have.

Additional Context

It should count ingredients recursively so if a crafting recipe requires ingredients from another crafting recipe than it will count those ingredients also
E.g When crafting a 4k storage cell it requires a 4k storage component and the ingredients required for the 4k storage component should also be considered (if applicable)

commented

There are ways? Unless you are saying that they take too long to calculate?

For instance you could count up testing 1 than 2 than 3 until you no longer have enough materials or I’m not great at optimisations but maybe a kind of binary search where you test 1 than test 10 if you have enough materials than test 100 else if you don’t have enough test 5 etc. (so logarithmically increasing the maximum of the binary search)

commented

There is no way to know the amount before actually issuing a job for an exact amount.

commented

Calculate the ingredients required for 1
Then divide the amount in the system by the base ingredients
then get the smallest of those numbers, floor it and that's the amount

for(ingredient ing : calc_ingredients) {
    list.add(amountInSystem(ing) / ing.requiredAmount)
}
return Math.floor(list.smallest())