
Open And Close Non Player Inventories
I don't know my version or loader
Inventory Detection: The "Impossible" Datapack For years, the Minecraft technical community has searched for a reliable way to detect when a player opens or closes their inventory. Many said it was impossible.
This datapack introduces a revolutionary logic system that detects inventory states in real-time, allowing you to trigger commands the exact moment a player interacts with a chest, lectern, or even a beacon!
How It Works (The "Bug" Feature)This pack utilizes a unique behavior within Minecraft's advancement system. The "inventory_changed" advancement trigger is highly reliable—except for one specific quirk: it stops triggering while a player is inside a non-player inventory.
The Logic:Every single game tick (1/20th of a second), the pack briefly swaps the player’s head slot with a custom item and back again.This forced change attempts to fire an advancement, scoreboard tracks these fires.
If the advancement stops firing for even one tick, the system knows the player is currently viewing an inventory. The moment the advancement fires again, the system knows the inventory has been closed.
High Performance: Optimized to run every tick with minimal impact on MSPT (usually 0.1-0.2).
Multiplayer Compatible: Tested and verified to work with multiple players on a server simultaneously.
Developer Friendly: All functions and variables are prefixed with Cailem to prevent conflicts with your existing projects.
In Creative mode, the inventory triggers the advancement twice due to unique engine behavior. The pack can actually be used to detect if a player is specifically in the Creative menu!
Examples that are now possible: Loot Chests: Spawns a chest while mining that automatically cleans itself up the moment you close it. Lectern Traps: Triggers world events (like spawning a Warden) the second a player stops reading. Survival Flight: A flight mode that protects the player but force-closes the inventory to prevent "cheating" items.
BROKEN: While the audio is suppressed, Minecraft’s subtitles may still show Gear equips. Note that the rapid item swapping can trigger Skulk Sensors/Wardens. (This can be disabled via version-specific tags if needed).
Note: This is a technical resource intended for datapack creators and map makers. Knowledge of how to install and reference functions is recommended.
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.21.11, 26.1.2
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Modrinth — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — see the MC Java Mods guides for the full walkthrough.
- Downloads as Detect Open Menus 1.21.11-26.1.zip
- Download size: 5 KB
- Download link checked 22 Aug 2026 — working
These come from our own check of the pack file, not from the source page.