There might be a better way, but I’ve found that this returns the chest’s inventory:
GridInventory chestInventory = container.query(GridInventory.class).first();
As you said, querying for
GridInventory returns two of them. The first one seems to always be the chest.
If you don’t care about it being a
GridInventory, you can just use