An exception is now thrown when referenced blocks and items are null and fixed an invalid reference to coral in BOPCrafting. Closes #258

This commit is contained in:
Adubbz 2014-05-19 10:34:35 +10:00
parent cc133672ef
commit ed7836c193
3 changed files with 12 additions and 3 deletions

View file

@ -9,6 +9,10 @@ public class BOPBlockHelper
{ {
public static Block get(String name) public static Block get(String name)
{ {
Block block = GameRegistry.findBlock(BOPModInfo.modID, name);
if (block == null) throw new RuntimeException("The referenced block is null!");
return GameRegistry.findBlock(BOPModInfo.modID, name); return GameRegistry.findBlock(BOPModInfo.modID, name);
} }

View file

@ -1,5 +1,6 @@
package biomesoplenty.api; package biomesoplenty.api;
import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial;
@ -19,6 +20,10 @@ public class BOPItemHelper
public static Item get(String name) public static Item get(String name)
{ {
Item item = GameRegistry.findItem(BOPModInfo.modID, name);
if (item == null) throw new RuntimeException("The referenced item is null!");
return GameRegistry.findItem(BOPModInfo.modID, name); return GameRegistry.findItem(BOPModInfo.modID, name);
} }

View file

@ -259,7 +259,7 @@ public class BOPCrafting
GameRegistry.addRecipe(new ItemStack(BOPBlockHelper.get("planks"), 1, 10), new Object[] {"##", "##", '#', BOPBlockHelper.get("bamboo")}); GameRegistry.addRecipe(new ItemStack(BOPBlockHelper.get("planks"), 1, 10), new Object[] {"##", "##", '#', BOPBlockHelper.get("bamboo")});
GameRegistry.addRecipe(new ItemStack(BOPItemHelper.get("jarEmpty"), 3, 0), new Object[] {"# #", "# #", "###", '#', Blocks.glass}); GameRegistry.addRecipe(new ItemStack(BOPItemHelper.get("jarEmpty"), 3, 0), new Object[] {"# #", "# #", "###", '#', Blocks.glass});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItemHelper.get("food"), 1, 10), new Object[] {new ItemStack(BOPItemHelper.get("misc"), 1, 11), new ItemStack(Items.potionitem, 1, 0), new ItemStack(BOPBlockHelper.get("flowers2"), 1, 6), new ItemStack(BOPBlockHelper.get("coral"), 1, 3), new ItemStack(BOPBlockHelper.get("plants"), 1, 15), new ItemStack(BOPItemHelper.get("misc"), 1, 4), new ItemStack(BOPItemHelper.get("jarFilled"), 1, 0), new ItemStack(BOPItemHelper.get("food"), 1, 0), Items.sugar}); GameRegistry.addShapelessRecipe(new ItemStack(BOPItemHelper.get("food"), 1, 10), new Object[] {new ItemStack(BOPItemHelper.get("misc"), 1, 11), new ItemStack(Items.potionitem, 1, 0), new ItemStack(BOPBlockHelper.get("flowers2"), 1, 6), new ItemStack(BOPBlockHelper.get("coral1"), 1, 11), new ItemStack(BOPBlockHelper.get("plants"), 1, 15), new ItemStack(BOPItemHelper.get("misc"), 1, 4), new ItemStack(BOPItemHelper.get("jarFilled"), 1, 0), new ItemStack(BOPItemHelper.get("food"), 1, 0), Items.sugar});
GameRegistry.addRecipe(new ItemStack(BOPBlockHelper.get("flesh"), 1, 0), new Object[] {"##", "##", '#', new ItemStack(BOPItemHelper.get("misc"), 1, 3)}); GameRegistry.addRecipe(new ItemStack(BOPBlockHelper.get("flesh"), 1, 0), new Object[] {"##", "##", '#', new ItemStack(BOPItemHelper.get("misc"), 1, 3)});
GameRegistry.addRecipe(new ItemStack(Items.rotten_flesh, 1, 0), new Object[] {"FFF", "FPF", "FFF", 'F', new ItemStack(BOPItemHelper.get("misc"), 1, 3), 'P', new ItemStack(BOPItemHelper.get("jarFilled"), 1, 1)}); GameRegistry.addRecipe(new ItemStack(Items.rotten_flesh, 1, 0), new Object[] {"FFF", "FPF", "FFF", 'F', new ItemStack(BOPItemHelper.get("misc"), 1, 3), 'P', new ItemStack(BOPItemHelper.get("jarFilled"), 1, 1)});