Solved SetItemInMainHand makes the item unstackable.

Discussion in 'Plugin Development' started by Deathoffully, Jan 6, 2019.

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



    After setting the held item of a player the item(-stack) behaves odd. It becomes unstackable with other items. Trying to stack it with other items manually doesn't work and when picking up items of that type they start stacking in a different slot even though they should be stacking in the held item slot.

    I set the item like this
    inventory.setItem(inventory.getHeldItemSlot(), new ItemStack(Material.DIRT));
    When trying to stack the dirt with other dirt the held dirt behaves like a different type of item would behave.
    Using setItemInMainHand results in the same outcome.

    Any ideas why that happens and how to fix it? I don't want to mess with pickup-events if I don't have to.

    EDIT: It works now, seems like my inventory bugged out or something. I didn't change anything but it works now.

    EDIT: It's back again - I have no clue what causes this.

    EDIT: So far the bug only occurred on a local server and not on a 3rd party server.
    Last edited: Jan 8, 2019
  2. Offline


    Have you tried looking through the itemmeta after you set it?

    Maybe compare it against what is in there for an item already in the inventory?
  3. Offline


    @torpkev I stopped investigating and I won't start again since this bug only occurred on my local server. Thank you for your help anyways.
    I'm going to mark this thread as solved even though I don't feel like it is.
Thread Status:
Not open for further replies.

Share This Page