diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java index 36e5591b..f518ebc7 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java @@ -5,6 +5,8 @@ import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.util.LogHelper; +import com.google.common.collect.Lists; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; @@ -12,6 +14,7 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.Arrays; +import java.util.Iterator; import java.util.List; public class ShapedRecipesRenderer extends BasicRecipeRenderer { @@ -20,6 +23,7 @@ public ShapedRecipesRenderer(ShapedRecipes recipe) { super(recipe); } + @SuppressWarnings("ConstantConditions") @Override public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); @@ -30,6 +34,13 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int Ingredient ingredient = recipe.getIngredients().get(y * recipe.recipeWidth + x); List list = Arrays.asList(ingredient.getMatchingStacks()); + List removeList = Lists.newArrayList(); + for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { + ItemStack testStack = iterator.next(); + if (testStack == null || testStack.getItem() == null) + removeList.add(testStack); + } + list.removeAll(removeList); if (!list.isEmpty()) { ItemStack stack = list.get(getRandomizedCycle(x + (y * 3), list.size())); if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java index 10733a3b..e8826f42 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java @@ -6,6 +6,7 @@ import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; +import com.google.common.collect.Lists; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; @@ -13,6 +14,7 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.Arrays; +import java.util.Iterator; import java.util.List; public class ShapelessRecipesRenderer extends BasicRecipeRenderer { @@ -21,6 +23,7 @@ public ShapelessRecipesRenderer(ShapelessRecipes recipe) { super(recipe); } + @SuppressWarnings("ConstantConditions") @Override public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); @@ -32,6 +35,13 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int if (i < recipe.getIngredients().size()) { Ingredient ingredient = recipe.getIngredients().get(i); List list = Arrays.asList(ingredient.getMatchingStacks()); + List removeList = Lists.newArrayList(); + for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { + ItemStack testStack = iterator.next(); + if (testStack == null || testStack.getItem() == null) + removeList.add(testStack); + } + list.removeAll(removeList); if (!list.isEmpty()) { ItemStack stack = list.get(getRandomizedCycle(x + (y * 3), list.size())); if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE)