From 989f12e65bca341405ed45ae2e038adff466b502 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 10 Mar 2012 15:43:48 -0500 Subject: [PATCH] Fixed NPE when breaking placed Herbalism blocks. --- .../com/gmail/nossr50/skills/Herbalism.java | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/Herbalism.java index a773eadba..16c9ac413 100644 --- a/src/main/java/com/gmail/nossr50/skills/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/Herbalism.java @@ -106,6 +106,7 @@ public class Herbalism { int herbLevel = PP.getSkillLevel(SkillType.HERBALISM); int id = block.getTypeId(); Material type = block.getType(); + Byte data = block.getData(); Location loc = block.getLocation(); Material mat = null; @@ -208,30 +209,35 @@ public class Herbalism { break; } - ItemStack is = new ItemStack(mat); - - if (herbLevel > 1000 || (Math.random() * 1000 <= herbLevel)) { - if (type.equals(Material.CACTUS)) { - m.mcDropItems(loc, is, catciDrops); - } - else if (type.equals(Material.MELON_BLOCK)) { - m.mcDropItems(loc, is, 3); - m.mcRandomDropItems(loc, is, 50, 4); - } - else if (type.equals(Material.NETHER_WARTS)) { - m.mcDropItems(loc, is, 2); - m.mcRandomDropItems(loc, is, 50, 3); - } - else if (type.equals(Material.SUGAR_CANE_BLOCK)) { - m.mcDropItems(loc, is, caneDrops); - } - else { - m.mcDropItem(loc, is); - } + if (mat == null) { + return; } + else { + ItemStack is = new ItemStack(mat); - PP.addXP(SkillType.HERBALISM, xp, player); - Skills.XpCheckSkill(SkillType.HERBALISM, player); + if (herbLevel > 1000 || (Math.random() * 1000 <= herbLevel)) { + if (type.equals(Material.CACTUS)) { + m.mcDropItems(loc, is, catciDrops); + } + else if (type.equals(Material.MELON_BLOCK)) { + m.mcDropItems(loc, is, 3); + m.mcRandomDropItems(loc, is, 50, 4); + } + else if (type.equals(Material.NETHER_WARTS)) { + m.mcDropItems(loc, is, 2); + m.mcRandomDropItems(loc, is, 50, 3); + } + else if (type.equals(Material.SUGAR_CANE_BLOCK)) { + m.mcDropItems(loc, is, caneDrops); + } + else { + m.mcDropItem(loc, is); + } + } + + PP.addXP(SkillType.HERBALISM, xp, player); + Skills.XpCheckSkill(SkillType.HERBALISM, player); + } } /**