From 859d4f5372ff835b7f3af8bcfa8d7f6e7fc37da3 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 28 Apr 2012 20:22:17 -0700 Subject: [PATCH] Fixed Green Thumb consuming 2 seeds instead of 1 --- Changelog.txt | 1 + .../com/gmail/nossr50/skills/Herbalism.java | 31 +++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 37ac9f011..d9bbc3b69 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,6 +14,7 @@ Version 1.3.06 + Added API functions for admin & party chat + Added Iron Grip skill to Unarmed which gives players an chance to keep from being disarmed. + Added some new languages to the locale files. + = Fixed Green Thumb consuming 2 seeds instead of 1 = Fixed exploit where you could teleport to yourself with PTP to prevent things like fall damage = Fixed NPE error with Metrics on startup = Fixed bug where Herbalism required double drops permission to give XP diff --git a/src/main/java/com/gmail/nossr50/skills/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/Herbalism.java index 76a98a53f..2560e3d9a 100644 --- a/src/main/java/com/gmail/nossr50/skills/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/Herbalism.java @@ -35,7 +35,6 @@ public class Herbalism { public static void greenTerra(Player player, Block block) { PlayerInventory inventory = player.getInventory(); boolean hasSeeds = inventory.contains(Material.SEEDS); - Material type = block.getType(); if (!hasSeeds) { player.sendMessage("You need more seeds to spread Green Terra"); //TODO: Needs more locale. @@ -43,17 +42,23 @@ public class Herbalism { else if (hasSeeds && !block.getType().equals(Material.WHEAT)) { inventory.removeItem(new ItemStack(Material.SEEDS)); player.updateInventory(); - - if (Misc.blockBreakSimulate(block, player, false)) { - if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type.equals(Material.SMOOTH_BRICK)) { - block.setData((byte) 0x1); //Set type of the brick to mossy - } - else if (Config.getInstance().getHerbalismGreenThumbDirtToGrass() && type.equals(Material.DIRT)) { - block.setType(Material.GRASS); - } - else if (Config.getInstance().getHerbalismGreenThumbCobbleToMossy() && type.equals(Material.COBBLESTONE)) { - block.setType(Material.MOSSY_COBBLESTONE); - } + greenTerraConvert(player, block); + + } + } + + public static void greenTerraConvert(Player player, Block block) { + Material type = block.getType(); + + if (Misc.blockBreakSimulate(block, player, false)) { + if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type.equals(Material.SMOOTH_BRICK)) { + block.setData((byte) 0x1); //Set type of the brick to mossy + } + else if (Config.getInstance().getHerbalismGreenThumbDirtToGrass() && type.equals(Material.DIRT)) { + block.setType(Material.GRASS); + } + else if (Config.getInstance().getHerbalismGreenThumbCobbleToMossy() && type.equals(Material.COBBLESTONE)) { + block.setType(Material.MOSSY_COBBLESTONE); } } } @@ -302,7 +307,7 @@ public class Herbalism { player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1)); if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= skillLevel) { - greenTerra(player, block); + greenTerraConvert(player, block); } else { player.sendMessage(LocaleLoader.getString("mcPlayerListener.GreenThumbFail"));