Inventory Manager
Kore’s Inventory Manager lets you declaratively control inventories on entities or blocks and react to slot events.
- Manage items in any
ContainerArgument(players, entities, or block containers). - Register slot listeners that fire when an item is taken from a slot.
- Keep a slot populated, clear other slots, or run custom logic every tick.
- Auto-generate the required load/tick functions and minimal scoreboards to drive the listeners.
Quick start
Tip: Use the builder variant to both declare listeners and auto-generate them in one go:
Block containers
You can target block inventories as well by passing a Vec3 and (optionally) placing a container block first:
API overview
inventoryManager(container)– Create a manager for anyContainerArgument(EntityArgumentorVec3).slotEvent(slot, expectedItem) { … }– Register handlers for a single slot.onTake { … }– Fires once when the slot transitions from expected item to something else.duringTake { … }– Fires every tick while the slot is not holding the expected item; useful to enforce state.onTick { … }– Runs every tick regardless of state; convenient for housekeeping.- Helpers inside the scope:
setItemInSlot()– Put back the expected item into the slot.clearAllItemsNotInSlot([targets])– Clear all other slots.killAllItemsNotInSlot()– Remove dropped items that don’t belong to this slot.
generateSlotsListeners()– Emits theload/tickfunctions and scoreboard wiring for all registered listeners.setBlock(block)– When the container is a position, place a block (e.g., a chest) before managing its contents.clear(slot),clearAll(),clearAll(item)– Utilities to wipe inventory content.
Internally, Inventory Manager relies on a scoreboard objective and a tiny helper marker entity (for non-entity containers) to detect state transitions. Names are auto-namespaced and unique per datapack.
Removing detectors
To clean up objectives created by Inventory Manager across runs:
Full example
This combines a player inventory policy with messaging and a chest that constantly re-seeds its first slot. It mirrors the test coverage used in Kore’s own suite.
See also
- Scheduler – Run repeated or delayed logic that complements inventory policies.
- Components – Define complex items (names, lore, enchantments) you can enforce in slots.
- Predicates – Validate component-based item properties in other contexts.
- Scoreboards – Background knowledge on objectives used under the hood.
