From 98511136ee42df7de08ab121aa9edb0dffb8be7e Mon Sep 17 00:00:00 2001 From: Dor Date: Sat, 12 Mar 2016 20:35:19 +0200 Subject: [PATCH] Fix Shroom Thumb not removing the item held. --- .../gmail/nossr50/listeners/PlayerListener.java | 1 + .../nossr50/skills/herbalism/HerbalismManager.java | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 75e76353d..57dfdcaa9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -566,6 +566,7 @@ public class PlayerListener implements Listener { /* SHROOM THUMB CHECK */ else if (herbalismManager.canUseShroomThumb(blockState)) { + event.setCancelled(true); if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) { blockState.update(true); } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 393fa6b4e..4ab0bff76 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -57,10 +57,10 @@ public class HerbalismManager extends SkillManager { public boolean canUseShroomThumb(BlockState blockState) { Player player = getPlayer(); - ItemStack item = player.getInventory().getItemInMainHand(); - Material itemType = item.getType(); + PlayerInventory inventory = player.getInventory(); + Material itemType = inventory.getItemInMainHand().getType(); - return item.getAmount() > 0 && (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockUtils.canMakeShroomy(blockState) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB); + return (itemType == Material.BROWN_MUSHROOM || itemType == Material.RED_MUSHROOM) && inventory.contains(Material.BROWN_MUSHROOM, 1) && inventory.contains(Material.RED_MUSHROOM, 1) && BlockUtils.canMakeShroomy(blockState) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB); } public boolean canUseHylianLuck() { @@ -271,13 +271,13 @@ public class HerbalismManager extends SkillManager { public boolean processShroomThumb(BlockState blockState) { Player player = getPlayer(); PlayerInventory playerInventory = player.getInventory(); - - if (!playerInventory.contains(Material.BROWN_MUSHROOM)) { + + if (!playerInventory.contains(Material.BROWN_MUSHROOM, 1)) { player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM))); return false; } - if (!playerInventory.contains(Material.RED_MUSHROOM)) { + if (!playerInventory.contains(Material.RED_MUSHROOM, 1)) { player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM))); return false; } @@ -326,7 +326,7 @@ public class HerbalismManager extends SkillManager { break; } - if (!playerInventory.containsAtLeast(seed, 1)) { + if (!playerInventory.contains(seed, 1)) { return; }