Solved PlayerIteractEvent removing interacted item

Discussion in 'Plugin Development' started by Artellet, Jun 16, 2018.

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

    Artellet

    I'm trying to remove the item the player is interacting with, however, every time I try to I run into a wall.

    Everything I've tried:
    p.setItemOnCursor(null); - Does nothing.
    p.setItemOnCursor(new ItemStack(Material.AIR)); - Does nothing.
    event.getItem().setType(Material.AIR); - Does nothing.
    p.getInventory.remove(event.getItem()); - Removes all of the same items rather than just the interacted item.
    p.getInventory.removeItem(event.getItem()); - Doesn't remove the item in the off hand, but does if it's on the hotbar. Also has an issue with removing the same item from the inventory/hotbar before the interacted item.

    I need this to be cross-version compatible, and this is the only way I know how to do so.
     
    Last edited: Jun 16, 2018
  2. Can you give us the entire Event code? It's hard to help you without any context.
     
    MightyOne likes this.
  3. Offline

    CommonSenze

    @Artellet
    Just get the ItemOnCursor and set the type to air. Or use getItemInHand and try it like that
     
  4. Set item to air with get...setType or set(new Ite... and start «runTaskLater» for 1 or 0.1 ticks and add in run method
    p.updateInventory();
     
    Last edited by a moderator: Jun 18, 2018
  5. Offline

    Artellet

    Did you even read the post?
     
  6. Offline

    CommonSenze

    @Artellet
    You never tried my ideas. They worked for me so :/
     
  7. Online

    timtower Administrator Administrator Moderator

    Then please post your full code so we can see the context of this.
     
  8. Offline

    Artellet

    I solved the issue by using two separate methods using some version utilities.
     
Thread Status:
Not open for further replies.

Share This Page