Add a way to find all matches at once for recipematches

This commit is contained in:
Bernhard Bonigl committed 2016-06-05 17:47:55 +02:00
1 parent 3ff8b2d60f
commit 7925eb0665
1 file changed
+23
@@ -63,6 +63,29 @@ public class RecipeMatchRegistry {
return new RecipeMatch.Match(foundStacks, sum);
}
public RecipeMatch.Match matchesRecursively(ItemStack[] stacks) {
stacks = copyItemStackArray(stacks); // copy so we don't modify original
List<RecipeMatch.Match> matches = Lists.newLinkedList();
RecipeMatch.Match match;
int sum = 0;
while((match = matches(stacks)) != null) {
matches.add(match);
RecipeMatch.removeMatch(stacks, match);
sum += match.amount;
}
// merge all found matches into one match
List<ItemStack> foundStacks = Lists.newLinkedList();
for(RecipeMatch.Match m : matches) {
foundStacks.addAll(m.stacks);
}
return new RecipeMatch.Match(foundStacks, sum);
}
/**
* Associates an oredict entry with this material. Used for repairing and other.
*