Are ItemStacks unique in some way?

Discussion in 'Plugin Development' started by w00tklumpWn, Jan 31, 2012.

Thread Status:
Not open for further replies.
  1. Hi!

    I'm working with the onPlayerInteract event. If i save the item form event.getItem() and compare them in the next event, they do not equal.

    Code:JAVA
    1.  
    2. ItemStack lastStack = getLastStack();
    3. if(lastStack == event.getItem())
    4. //do something
    5. else
    6. lastStack = event.getItem();
    7.  


    This will never come true. I'm looking for an id or something. Why either use a new instance/clone of the item used in the called event?
     
  2. tried
    Code:
    if(lastStack.equals(event.getItem()))
    ?
     
  3. Offline

    troed

  4. Nope. It has to be exact the same instance. If you have 2 wooden shovels and you equal em it's still true. But i need the exact item.

    Thanks for that, but i think thats not what i am looking for.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  5. Offline

    nisovin

    The answer is no, ItemStacks are not unique or identifiable in any useful way. If you use enchantable items, you can use the workaround described in that thread that was linked.
     
Thread Status:
Not open for further replies.

Share This Page