Skip to content

Commit

Permalink
null fixes for ItemBlockGenerator. Fixes #5081
Browse files Browse the repository at this point in the history
  • Loading branch information
thiakil committed Jun 14, 2018
1 parent fa64372 commit c93f030
Showing 1 changed file with 11 additions and 6 deletions.
Expand Up @@ -92,7 +92,7 @@ public int getItemStackLimit(ItemStack stack)
{
GeneratorType type = GeneratorType.get(stack);

if(type.maxEnergy == -1)
if(type!=null && type.maxEnergy == -1)
{
return 64;
}
Expand All @@ -110,19 +110,22 @@ public int getMetadata(int i)
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
if(GeneratorType.get(itemstack) == null)
GeneratorType generatorType = GeneratorType.get(itemstack);
if(generatorType == null)
{
return "KillMe!";
}

return getUnlocalizedName() + "." + GeneratorType.get(itemstack).blockName;
return getUnlocalizedName() + "." + generatorType.blockName;
}

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, World world, List<String> list, ITooltipFlag flag)
{
GeneratorType type = GeneratorType.get(itemstack);
if (type==null)
return;

if(type.maxEnergy > -1)
{
Expand Down Expand Up @@ -343,7 +346,8 @@ public void setEnergy(ItemStack itemStack, double amount)
@Override
public double getMaxEnergy(ItemStack itemStack)
{
return GeneratorType.get(itemStack).maxEnergy;
GeneratorType generatorType = GeneratorType.get(itemStack);
return generatorType != null ? generatorType.maxEnergy : 0;
}

@Override
Expand All @@ -361,7 +365,8 @@ public boolean canReceive(ItemStack itemStack)
@Override
public boolean canSend(ItemStack itemStack)
{
return GeneratorType.get(itemStack).maxEnergy != -1;
GeneratorType generatorType = GeneratorType.get(itemStack);
return generatorType != null && generatorType.maxEnergy != -1;
}

@Override
Expand Down Expand Up @@ -470,7 +475,7 @@ public boolean hasSecurity(ItemStack stack)
{
GeneratorType type = GeneratorType.get(stack);

return type.hasModel;
return type!=null && type.hasModel;
}

@Override
Expand Down

0 comments on commit c93f030

Please sign in to comment.