Solved ID changes when you rename an itemstack?

Discussion in 'Plugin Development' started by Froshin, May 21, 2013.

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

    Froshin

    Hi.

    Whenever a player right clicks with a diamond, it's supposed to be destroyed, one at a time. This was no issue at all to fix.


    The problem is that I want to change the name of the diamond on pickup, which also works fine.
    (I have also changed the color value through ChatColor.BLUE)
    However, once it is renamed it does not work anymore. Any clues on why?

    Edit: In the process of retriving the ID now through in-game testing means. I don't know why I was so eager to make a topic, but please respond nontheless. Otherwise I will update with the soloution. :)

    Edit2: It returns the same ID ( 264 ) as a normal diamond, which is all I am checking for before removing the diamond?? :eek:

    Thanks in advance!
     
  2. Offline

    Jogy34

    I'm guessing you are trying to remove the item from the player's inventory by sending in an ItemStack. The problem with that is when you change the ItemMeta within an ItemStack it is different from a new ItemStack with the same Material in it with the same amount of items.
     
    Froshin likes this.
  3. Offline

    Froshin

    Jogy34
    Thank you!


    I solved it through simply writing:


    ItemStack Is = new ItemStack(e.getItem().getTypeId(), 1);
    ItemMeta Im = e.getItem().getItemMeta();
    Is.setItemMeta(Im);

    The reason the error was in the first place was because I defined the itemstack like so:

    ItemStack Is = new ItemStack(e.getItem().getTypeId(), 1);

    So it wouldn't remove an entire stack. Which led to the problem that the Is was simply a copy of a vanilla diamond. :)
     
Thread Status:
Not open for further replies.

Share This Page