/ClickInventoryEvent. Check, player clicked on inventory slot, or chest slot?

How I can check, player clicked on inventory(2) slot, or chest(1) slot?
http://s014.radikal.ru/i328/1706/0a/088ba4564213.jpg

In sponge. Inventories break down into sections. So in this case section 2 and 3 is a Carrier Inventory. Then that can be broken down into the two sections. Section 2 from there is known as a GridInventory while section 3 is a Hotbar.

From there you should be able to check the slots in each section. If the item in the clicked slot matches the item in the selected slot then what ever part of the inventory you are looking at is it. If its not in either then its in section 1.

Here are some bits of code that may help you.

Inventory.getProperties(Hotbar.class);

Inventory.getSlots();

I can`t use Inventory::getProperties(Hotbar.class);
Because Hotbar isn`t “InventoryProperty”.
Did you mean Inventory::query(Hotbar.class)?
Anyway, it helps not so much…
I found that my Container consist of three parts:

  1. OrderedIventory (Chest(1))
  2. GridInventory (Player inventory(2))
  3. Hotbat (hotbar obviously(3))
    How I can check, that clicked Slot is from OrderedInventory?
    I think comparing items is not good idea, player can have the same item as chest…
2 Likes

But you could also compare the items. E.g. by adding custom data to it.