ItemInHand()

Discussion in 'Plugin Development' started by Higgsboson728, Dec 6, 2015.

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

    Higgsboson728

    Hello, I want to check if a person has exactly one item in his/her hand.

    This is the code I use so far, but it doesn't work.

    Code:
    if (player.getItemInHand().getAmount == 1)
    {
    player.getItemInHand().setAmount(0);
    }
    Is there any workaround for this?

    Thanks!

    ~~Higgsboson728
     
  2. Offline

    vhbob

    @Higgsboson728 im pretty sure you cant set the amount to 0, maybe set it to null???
     
  3. Offline

    Higgsboson728

    I'll try it out, thanks!

    @vhbob

    EDIT:
    I need to add a cast to "null". What should I put there?
     
  4. Offline

    vhbob

  5. Offline

    Higgsboson728

    Sorry for double posting.

    @vhbob

    The method setAmount(int) in the type ItemStack is not applicable for the arguments (null)
     
  6. Offline

    BrickBoy55

    @Higgsboson728 If you're trying to get rid of them item, can't you just use player.setItemInHand(null); (I'm pretty sure thats what the method is)
     
Thread Status:
Not open for further replies.

Share This Page