Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle invalid ItemStacks when rendering PageIRecipes #96

Open
wants to merge 3 commits into
base: 1.12
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use iterator in the list
The-Fireplace committed Sep 2, 2018
commit 7de09d11c4f20fb9fdbd0ae14057a0b7922d140d
Original file line number Diff line number Diff line change
@@ -14,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<ShapedRecipes> {
@@ -34,9 +35,11 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int
Ingredient ingredient = recipe.getIngredients().get(y * recipe.recipeWidth + x);
List<ItemStack> list = Arrays.asList(ingredient.getMatchingStacks());
List<ItemStack> removeList = Lists.newArrayList();
for(ItemStack testStack:list)
if(testStack == null || testStack.getItem() == null)
for (Iterator<ItemStack> 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()));
Original file line number Diff line number Diff line change
@@ -14,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<ShapelessRecipes> {
@@ -35,9 +36,11 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int
Ingredient ingredient = recipe.getIngredients().get(i);
List<ItemStack> list = Arrays.asList(ingredient.getMatchingStacks());
List<ItemStack> removeList = Lists.newArrayList();
for(ItemStack testStack:list)
if(testStack == null || testStack.getItem() == null)
for (Iterator<ItemStack> 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()));