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
Next Next commit
Properly handle invalid ItemStacks when rendering PageIRecipes
The-Fireplace committed Aug 21, 2017
commit d6fec167cb0fea34212e1d26fc54738a743e7a32
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import amerifrance.guideapi.api.impl.abstraction.EntryAbstract;
import amerifrance.guideapi.api.util.GuiHelper;
import amerifrance.guideapi.gui.GuiBase;
import amerifrance.guideapi.util.LogHelper;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
@@ -20,6 +21,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 +32,9 @@ 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());
for(ItemStack testStack:list)
if(testStack == null || testStack.getItem() == null)
list.remove(testStack);
if (!list.isEmpty()) {
ItemStack stack = list.get(getRandomizedCycle(x + (y * 3), list.size()));
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE)
Original file line number Diff line number Diff line change
@@ -21,6 +21,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 +33,9 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int
if (i < recipe.getIngredients().size()) {
Ingredient ingredient = recipe.getIngredients().get(i);
List<ItemStack> list = Arrays.asList(ingredient.getMatchingStacks());
for(ItemStack testStack:list)
if(testStack == null || testStack.getItem() == null)
list.remove(testStack);
if (!list.isEmpty()) {
ItemStack stack = list.get(getRandomizedCycle(x + (y * 3), list.size()));
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE)