mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-26 06:42:57 +00:00
Add a way to find all matches at once for recipematches
This commit is contained in:
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.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user