Issue with querying inventory


No matter what method I have tried, the bottom row of the survival inventory is not readable.

This is my inventory:

Inventory main = player.getInventory().query(MainPlayerInventory.class);
for(int y = 0; y < 4; y++){
    for(int x = 0; x < 9; x++){
        Optional<Slot> slot = ((MainPlayerInventory) main).getGrid().getSlot(x, y);

This snipped produces the following output:

As you can see, the GridInventory encompasses the hotbar and the top two rows of the survival inventory. Through no method have I been able to read the bottom row, including querying the parent inventory.

Is this (heaven forbid) an intentional feature of Spigot? What am I doing incorrectly, here?


the hotbar is not part of the main inventory if i remember correctly. try using Hotbar.class instead


The trouble is, the inventory is acting as if the hotbar IS part of the main inventory, but the bottom row of the actual main inventory is not. So, the “main inventory” that Sponge offers consists of the hotbar and the top two rows of the actual main inventory.


oh, now i see, can you try getting InventoryRow.class? the 3rd row not being part might be a bug :thinking:


It’s the same story. There are 3 rows in the GridInventory, and one of them is the hotbar.


Well, what do you know? I queried the Hotbar, and it is mapped to the bottom row of the main inventory. I’m going to call that a bug.