Solved setItemInHand() not working?

Discussion in 'Plugin Development' started by techboy291, Dec 1, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    techboy291

    Hi,

    I know this question might sound a bit silly, but I was trying to make a simple souping mechanism and I can't seem to set the item as a bowl after I soup.

    Code:
    @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event)
        {
            Player player = event.getPlayer();
            Action action = event.getAction();
            if(player.getItemInHand().getType().equals(Material.MUSHROOM_SOUP) && (action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK)))
            {
                double health = player.getHealth();
                if(health <= 13)
                {
                    player.setHealth(health + 7.0);
                } else if(health < 20)
                {
                    player.setHealth(20.0);
                }
                player.getInventory().setItemInHand(new ItemStack(Material.BOWL, 1));
                player.updateInventory();
                event.setCancelled(true);
            }
        }
    I've tried using player.setItemInHand() too; that didn't work either. Thanks in advance.
     
  2. Offline

    user_90854156

    Code:java
    1. player.getItemInHand().setType(Material.BOWL);

    I use this in my soup plugin ^
     
    techboy291 likes this.
  3. Offline

    techboy291

    Oh, thanks! It works.
     
    user_90854156 likes this.
Thread Status:
Not open for further replies.

Share This Page