Solved 1.14.4 ItemStack linked with inventory slot

Discussion in 'Spigot Plugin Development' started by Chr0n4s, Oct 8, 2019.

Thread Status:
Not open for further replies.
  1. Hey,

    i dont know if this is a bug or so.

    I got a problem with ItemStack:
    Add item to chest inventory slot 0;
    Get the ItemStack from chest inventory slot 0 -> Saving it as ItemStack;
    Remove the item from chest slot 0 -> Saved ItemStack is now air;

    I cant find any hint in the API overview for why the ItemStack saves the inventory.
     
  2. BTW
    If i serialize the ItemStack it doesnt save any inventory linked stuff.
    So when i deserialize it it is just an normal itemstack without the weard link to the inventory slot.
     
  3. Because you're probably saving a reference to the ItemStack instead of a copy of it. Try to save your ItemStack with ItemStack copy = original.clone();
     
    #3 Gadse, Oct 8, 2019
    Last edited: Oct 8, 2019
  4. I believe what you mean to say is original.clone()
     
    • Agree Agree x 1
  5. OMG im embarrassed. That was the problem TY
     
Thread Status:
Not open for further replies.