Check if player has ANY gui open?

I want a simple boolean returning whether or not the player is viewing an inventory, whether it be: Their own inventory, crafting table, a chest, hopper, etc.

I have tried using:


but it always returns true, even if the player has no gui open.

Is it possible?

That seems to be a bug. Report it to sponges github.

A workaround would be to get the open inventory (returns a optional) and check that.

Due to the fact that the normal players inventory doesnt get sent to the server anymore when it is opened, im assuming that the isInventoryOpen function would not detect if the regular player inventory is opened.

For all other inventory archetypes, it should still be able to detect them.

Even if the player has no inventory open or has their own inventory open, it still returns that the inventory archetype is PLAYER.

As mentioned before, the player inventory probably can not be detected on the server side. So maybe just compare the architecture and check that it not players inventory

Right, but what I’m trying to do is allow a player to drop an item with the ‘q’ key if no inventory is open, but not allow them to throw it out of their inventory, with cursor, or by hitting ‘q’ in their inventory. This is why I was checking if it was possible.

Because minecraft removed the network packet for a players inventory opening, there is no way of checking if the players inventory is opened or not. So you will struggle to do what your attempting

The only thing i can really suggest is to check the slot that the dropped item came from, if it is in the hotbar or the players 2nd hand slot then it probably was dropped with ‘q’

There’s an event for dropping items from a inventory. You can cancel the event, but should be careful: Closing the inventory while an item is on the cursor tries to drop it and triggers the event resulting in the item being deleted, so you’ll have to clear the cursor manually and put the item back into the player inventory