Expand recipeMatch so it can be used for displaying purposes

This commit is contained in:
Bernhard Bonigl committed 2015-12-31 14:17:26 +01:00
1 parent c49810c24d
commit 4267584e00
1 file changed
+24
@@ -1,5 +1,6 @@
package slimeknights.mantle.util;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -34,6 +35,11 @@ public abstract class RecipeMatch {
this.amountNeeded = amountNeeded;
}
/**
* Return all possible inputs that are a single item, if applicable.
*/
public abstract List<ItemStack> getInputs();
public abstract Match matches(ItemStack[] stacks);
public static RecipeMatch of(String oredict) {
@@ -120,6 +126,11 @@ public abstract class RecipeMatch {
this.template = template;
}
@Override
public List<ItemStack> getInputs() {
return ImmutableList.of(template);
}
@Override
public Match matches(ItemStack[] stacks) {
List<ItemStack> found = Lists.newLinkedList();
@@ -158,6 +169,14 @@ public abstract class RecipeMatch {
this.itemStacks = stacks;
}
@Override
public List<ItemStack> getInputs() {
if(itemStacks.length == 0 || itemStacks.length > 1) {
return ImmutableList.of();
}
return ImmutableList.of(itemStacks[0]);
}
@Override
public Match matches(ItemStack[] stacks) {
List<ItemStack> found = Lists.newLinkedList();
@@ -206,6 +225,11 @@ public abstract class RecipeMatch {
this.oredictEntry = OreDictionary.getOres(oredictEntry);
}
@Override
public List<ItemStack> getInputs() {
return oredictEntry;
}
@Override
public Match matches(ItemStack[] stacks) {
List<ItemStack> found = Lists.newLinkedList();