Solved Check if player placed/picked up item(inventory)

Discussion in 'Plugin Development' started by xGamingDudex, Apr 19, 2013.

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


    Hi, I was wondering if it was possible to detect if the player is placing an item in an inventory. So when someone click in the inventory the InventoryClickEvent is called. There you can check isLeftClick, isRightClick, isShiftClick. But I want to know if the player is placing an item. Was thinking you could do it with some hashmap and booleans, like count how many times the player clicked, but if you are in creative you can use the PickBlock button to get a new stack of the item without any clicking. Any help would be appreciated.
  2. Offline


    getCursor () is an itemstack and getCurrentItem is empty?
  3. Offline


    Thanks, have tested a bit and getCursor() always return the item you did something with, like if you place stone it returns stone, if you pick up stone it return stone. But getCurrentItem() seams to when you are picking something up like picking up some stone then it returns stone, but if you place the stone then it returns air.
  4. xGamingDudex
    No it doesn't... getCursor() holds the item that you were holding before you clicked.

    So if you click an item with empty cursor the cursor will return null and getCurrentItem() will return the clicked item.

    Apart from left clicks you need to consider right clicks, shift clicks and when will be finally added to the API, middle clicks, because each is diferent.

    Also, you should just debug, print the values of getCursor() and getCurrentItem() in server console and move stuff around (game windowed so you see the console), then you'll understand how they go.
Thread Status:
Not open for further replies.

Share This Page