Added some Null Checks for stuffs

This commit is contained in:
Ellpeck 2015-10-30 21:42:14 +01:00
parent 7b9573ca8e
commit 96581ba7cf
5 changed files with 19 additions and 10 deletions

View file

@ -41,6 +41,21 @@ public class BookletPage{
this.id = id;
}
public void addToPagesWithItemStackData(){
if(!InitBooklet.pagesWithItemStackData.contains(this)){
ItemStack[] stacks = this.getItemStacksForPage();
if(stacks != null && stacks.length > 0){
//Ensure that there is at least one ItemStack
for(ItemStack stack : stacks){
if(stack != null){
InitBooklet.pagesWithItemStackData.add(this);
break;
}
}
}
}
}
public static void renderItem(GuiBooklet gui, ItemStack stack, int x, int y, float scale){
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);

View file

@ -12,7 +12,6 @@ package ellpeck.actuallyadditions.booklet.page;
import cpw.mods.fml.relauncher.ReflectionHelper;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.proxy.ClientProxy;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
@ -40,7 +39,7 @@ public class PageCrafting extends BookletPage{
public PageCrafting(int id, IRecipe... recipes){
super(id);
this.recipes = recipes;
InitBooklet.pagesWithItemStackData.add(this);
this.addToPagesWithItemStackData();
}
@Override

View file

@ -11,7 +11,6 @@
package ellpeck.actuallyadditions.booklet.page;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.proxy.ClientProxy;
import ellpeck.actuallyadditions.recipe.CrusherRecipeRegistry;
import ellpeck.actuallyadditions.util.ModUtil;
@ -34,7 +33,7 @@ public class PageCrusherRecipe extends BookletPage{
public PageCrusherRecipe(int id, CrusherRecipeRegistry.CrusherRecipe recipe){
super(id);
this.recipe = recipe;
InitBooklet.pagesWithItemStackData.add(this);
this.addToPagesWithItemStackData();
}
@Override

View file

@ -11,7 +11,6 @@
package ellpeck.actuallyadditions.booklet.page;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.proxy.ClientProxy;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
@ -35,7 +34,7 @@ public class PageFurnace extends BookletPage{
super(id);
this.result = result;
this.input = input;
InitBooklet.pagesWithItemStackData.add(this);
this.addToPagesWithItemStackData();
}
@Override

View file

@ -11,7 +11,6 @@
package ellpeck.actuallyadditions.booklet.page;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import net.minecraft.item.ItemStack;
public class PageTextOnly extends BookletPage{
@ -23,10 +22,8 @@ public class PageTextOnly extends BookletPage{
}
public PageTextOnly setStack(ItemStack stack){
if(!InitBooklet.pagesWithItemStackData.contains(this)){
InitBooklet.pagesWithItemStackData.add(this);
}
this.stack = stack;
this.addToPagesWithItemStackData();
return this;
}