From ed7836c19318efed5162b3dd5fe7369f81734ab9 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Mon, 19 May 2014 10:34:35 +1000 Subject: [PATCH] An exception is now thrown when referenced blocks and items are null and fixed an invalid reference to coral in BOPCrafting. Closes #258 --- src/main/java/biomesoplenty/api/BOPBlockHelper.java | 6 +++++- src/main/java/biomesoplenty/api/BOPItemHelper.java | 7 ++++++- src/main/java/biomesoplenty/common/core/BOPCrafting.java | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/biomesoplenty/api/BOPBlockHelper.java b/src/main/java/biomesoplenty/api/BOPBlockHelper.java index c1b8e4a4e..bf46b08f9 100644 --- a/src/main/java/biomesoplenty/api/BOPBlockHelper.java +++ b/src/main/java/biomesoplenty/api/BOPBlockHelper.java @@ -9,7 +9,11 @@ public class BOPBlockHelper { public static Block get(String name) { - return GameRegistry.findBlock(BOPModInfo.modID, 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); } public static String getUniqueName(Block block) diff --git a/src/main/java/biomesoplenty/api/BOPItemHelper.java b/src/main/java/biomesoplenty/api/BOPItemHelper.java index d9cd1fa25..67b79a92a 100644 --- a/src/main/java/biomesoplenty/api/BOPItemHelper.java +++ b/src/main/java/biomesoplenty/api/BOPItemHelper.java @@ -1,5 +1,6 @@ package biomesoplenty.api; +import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; @@ -19,7 +20,11 @@ public class BOPItemHelper public static Item get(String name) { - return GameRegistry.findItem(BOPModInfo.modID, 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); } public static String getUniqueName(Item item) diff --git a/src/main/java/biomesoplenty/common/core/BOPCrafting.java b/src/main/java/biomesoplenty/common/core/BOPCrafting.java index 33b1e13b1..917d7678d 100644 --- a/src/main/java/biomesoplenty/common/core/BOPCrafting.java +++ b/src/main/java/biomesoplenty/common/core/BOPCrafting.java @@ -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(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(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)});