Change TableRecipe to take the Ingredients in instead of the list of items, and remove an unneeded for loop when getting the recipe output.
@@ -48,19 +48,19 @@ public class TableRecipeFactory implements IRecipeFactory {
}
public static class TableRecipe extends ShapedOreRecipe {
- public final ItemStack[] outputBlocks; // first one found of these determines the output block used
+ public final Ingredient ingredients; // first one found of these determines the output block used
- public TableRecipe(ResourceLocation group, Ingredient ingredient, ItemStack result, ShapedPrimer primer) {
+ public TableRecipe(ResourceLocation group, Ingredient ingredientIn, ItemStack result, ShapedPrimer primer) {
super(group, result, primer);
- this.outputBlocks = ingredient.getMatchingStacks();
+ this.ingredients = ingredientIn;
}
@Nonnull
@Override
public ItemStack getCraftingResult(InventoryCrafting craftMatrix) {
for(int i = 0; i < craftMatrix.getSizeInventory(); i++) {
- for(ItemStack ore : outputBlocks) {
+ for(ItemStack ore : ingredients.getMatchingStacks()) {
ItemStack stack = craftMatrix.getStackInSlot(i);
if(OreDictionary.itemMatches(ore, stack, false) && Block.getBlockFromItem(stack.getItem()) != Blocks.AIR) {
BlockTable block = (BlockTable) Block.getBlockFromItem(output.getItem());
@@ -75,8 +75,8 @@ public class TableRecipeFactory implements IRecipeFactory {
@Nonnull
@Override
public ItemStack getRecipeOutput() {
- if(!(outputBlocks.length == 0) && !output.isEmpty()) {
- for(ItemStack stack : outputBlocks) {
+ if(!(ingredients.getMatchingStacks().length == 0) && !output.isEmpty()) {
+ ItemStack stack = ingredients.getMatchingStacks()[0];
BlockTable block = (BlockTable) Block.getBlockFromItem(output.getItem());
int meta = stack.getItemDamage();
@@ -86,7 +86,6 @@ public class TableRecipeFactory implements IRecipeFactory {
return BlockTable.createItemstack(block, output.getItemDamage(), Block.getBlockFromItem(stack.getItem()), meta);
}
- }
return super.getRecipeOutput();
}
