Solved Check If A Player Right Clicked On A Custom ItemStack

Discussion in 'Plugin Development' started by 16austin16, Jun 18, 2015.

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

    16austin16

    How can i check if a player right clicked on my itemstack that i mad this is the code i have tryed so far (I Already Have The Event To Check For Right Clicks)

    Code:
    if(p.getItemInHand().getItemMeta() == LuckyItem.meta) {
       Do Things
    }
    And Also
    Code:
    if(p.getItemInHand() == LuckyItem.luckyitem) {
         Do More Things
    }
    and right now i have the itemstack as a static method so i can accsess it in a different class
     
    Last edited: Jun 18, 2015
  2. Offline

    Drkmaster83

    Well... a few things.

    You're comparing them wrong. You should use .equals() when it comes to objects with more complexity than an enumeration.

    Additionally, an item returns true to .equals() only if the amount and stack data are the same. If you desire something different, try ItemStack#isSimilar(ItemStack is).
     
  3. Offline

    16austin16

    Thanks That Worked.
     
Thread Status:
Not open for further replies.

Share This Page