From a72971e042274baabc8aef38681c77bc9b89409b Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 7 Jan 2017 01:10:16 -0800 Subject: [PATCH] Fix #1562 Carpenter recipes not showing properly in JEI --- .../core/recipes/ShapedRecipeCustom.java | 4 +-- .../carpenter/CarpenterRecipeCategory.java | 3 ++- .../jei/carpenter/CarpenterRecipeWrapper.java | 27 ++++++++++++------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java b/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java index 6a12ff32c..654e6d605 100644 --- a/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java @@ -113,8 +113,8 @@ public class ShapedRecipeCustom extends ShapedOreRecipe implements IDescriptiveR } } - input = NonNullList.withSize(9, NonNullList.create()); - oreDicts = NonNullList.withSize(9, ""); + input = NonNullList.withSize(shape.length(), NonNullList.create()); + oreDicts = NonNullList.withSize(shape.length(), ""); int x = 0; for (char chr : shape.toCharArray()) { NonNullList stacks = itemMap.get(chr); diff --git a/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeCategory.java b/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeCategory.java index 13ca7fa25..e032b5515 100644 --- a/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeCategory.java +++ b/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeCategory.java @@ -82,7 +82,8 @@ public class CarpenterRecipeCategory extends ForestryRecipeCategory> craftingInputs = recipeWrapper.getInputStacks(); + craftingGridHelper.setInputs(guiItemStacks, craftingInputs, craftingGridRecipe.getWidth(), craftingGridRecipe.getHeight()); List> fluidInputs = ingredients.getInputs(FluidStack.class); if (!fluidInputs.isEmpty()) { diff --git a/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeWrapper.java b/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeWrapper.java index fa4edc2d7..ca1c82a4a 100644 --- a/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeWrapper.java +++ b/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeWrapper.java @@ -13,30 +13,35 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.fluids.FluidStack; public class CarpenterRecipeWrapper extends ForestryRecipeWrapper { + private final List> inputStacks; public CarpenterRecipeWrapper(ICarpenterRecipe recipe) { super(recipe); + + IDescriptiveRecipe craftingGridRecipe = recipe.getCraftingGridRecipe(); + NonNullList> inputs = craftingGridRecipe.getIngredients(); + + this.inputStacks = new ArrayList<>(); + for (List stacks : inputs) { + List copy = new ArrayList<>(); + copy.addAll(stacks); + this.inputStacks.add(copy); + } } @Override public void getIngredients(IIngredients ingredients) { ICarpenterRecipe recipe = getRecipe(); IDescriptiveRecipe craftingGridRecipe = recipe.getCraftingGridRecipe(); - NonNullList> inputs = craftingGridRecipe.getIngredients(); List> inputStacks = new ArrayList<>(); - for (List stacks : inputs) { - List copy = new ArrayList<>(); - copy.addAll(stacks); - if(!copy.isEmpty()){ - inputStacks.add(copy); - } - } - ItemStack box = recipe.getBox(); if (!box.isEmpty()) { inputStacks.add(Collections.singletonList(box)); } + + inputStacks.addAll(getInputStacks()); + ingredients.setInputLists(ItemStack.class, inputStacks); FluidStack fluidResource = recipe.getFluidResource(); @@ -47,4 +52,8 @@ public class CarpenterRecipeWrapper extends ForestryRecipeWrapper> getInputStacks() { + return inputStacks; + } }