Merge pull request #2810 from DorCoMaNdO/master

Fix Shroom Thumb not removing the item held.
This commit is contained in:
t00thpick1 2016-03-12 17:55:35 -05:00
commit d26779bee9
2 changed files with 8 additions and 7 deletions

View File

@ -566,6 +566,7 @@ public class PlayerListener implements Listener {
/* SHROOM THUMB CHECK */ /* SHROOM THUMB CHECK */
else if (herbalismManager.canUseShroomThumb(blockState)) { else if (herbalismManager.canUseShroomThumb(blockState)) {
event.setCancelled(true);
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) { if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true); blockState.update(true);
} }

View File

@ -57,10 +57,10 @@ public class HerbalismManager extends SkillManager {
public boolean canUseShroomThumb(BlockState blockState) { public boolean canUseShroomThumb(BlockState blockState) {
Player player = getPlayer(); Player player = getPlayer();
ItemStack item = player.getInventory().getItemInMainHand(); PlayerInventory inventory = player.getInventory();
Material itemType = item.getType(); 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() { public boolean canUseHylianLuck() {
@ -271,13 +271,13 @@ public class HerbalismManager extends SkillManager {
public boolean processShroomThumb(BlockState blockState) { public boolean processShroomThumb(BlockState blockState) {
Player player = getPlayer(); Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory(); 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))); player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
return false; 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))); player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
return false; return false;
} }
@ -326,7 +326,7 @@ public class HerbalismManager extends SkillManager {
break; break;
} }
if (!playerInventory.containsAtLeast(seed, 1)) { if (!playerInventory.contains(seed, 1)) {
return; return;
} }