InventoryFramework
InventoryFramework provides a data and event layer for inventory management. Designed to be consumed by a separate UI assembly as it has no UI of its own.
About this mod Author’s original text
InventoryFramework
A MelonLoader mod that provides a data and event layer for inventory management. Designed to be consumed by a separate UI assembly as it has no UI of its own.
Getting Started
Add a reference to InventoryFramework.dll in your project. The framework initializes itself via MelonLoader. You do not need to instantiate anything.
Items must be registered before they can be added to any inventory:
InventoryManager.Instance.RegisterItem(new ItemDefinition("wood", "Wood"));
InventoryManager.Instance.PlayerInventory.AddItem("wood", 5);
That first argument is the ID, and the second is the display name.
InventoryManager
The main entry point. Access via InventoryManager.Instance.
Properties
| Property | Type | Description |
| ----------------- | --------------------------------------------- | ------------------------------------- |
| Instance | InventoryManager | Singleton. |
| PlayerInventory | Inventory | The player's inventory. |
| SelectedItem | InventoryItem? | The currently selected item, or null. |
| Registry | IReadOnlyDictionary | All registered item definitions. |
Methods
| Method | Description |
| ---------------------------------- | --------------------------------------------------------------------- |
| RegisterItem(ItemDefinition def) | Registers an item definition. Throws if the ID is already registered. |
| GetItem(string id) | Returns the definition for a registered item ID. Throws if not found. |
| SelectItem(InventoryItem? item) | Sets the selected item and fires OnItemSelected. |
Events
| Event | Signature | Description |
| -------------------- | ------------------------ | ------------------------------------- |
| OnItemSelected | Action | Fired when the selected item changes. |
| OnItemUsed | Action | Fired on left mouse button down. |
| OnItemAltUsed | Action | Fired on right mouse button down. |
| OnInventoryKeyDown | Action | Fired on any key down. |
| OnItemRegistered | Action | Fired when a new item is registered. |
Inventory
Manages a collection of InventoryItems. Access the player inventory via InventoryManager.Instance.PlayerInventory.
Properties
| Property | Type | Description |
| -------- | ------------------------------ | ----------------------------------- |
| Items | IReadOnlyList | The current items in the inventory. |
Methods
| Method | Description |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| AddItem(string id, int quantity = 1) | Adds quantity to an existing stack, or creates a new one. |
| RemoveItem(string id, int quantity = 1) | Removes quantity from a stack. Removes the stack entirely if it reaches zero. Throws if the item is not in the inventory. |
| GetItem(string id) | Returns the InventoryItem for the given ID. Throws if not found. |
| HasItem(string id, int quantity = 1) | Returns true if the inventory contains at least the given quantity. |
| Clear() | Fires OnCleared, then removes all items and fires OnChanged. |
Events
| Event | Signature | Description |
| ----------------------- | ----------------------- | -------------------------------------------------------------------------------- |
| OnChanged | Action | Fired after any change to the inventory. |
| OnCleared | Action | Fired before the inventory is cleared. Items are still readable at this point. |
| OnItemAdded | Action | Fired when a new item stack is created. |
| OnItemRemoved | Action | Fired when an item stack is fully removed. Does not fire when Clear() is called. |
| OnItemQuantityChanged | Action | Fired when an existing stack's quantity changes. |
ItemDefinition
Defines a type of item. Create one per item type and register it with InventoryManager.RegisterItem.
Constructor
new ItemDefinition(string id, string name, Sprite? image = null)
Properties
| Property | Type | Description |
| -------- | --------- | --------------------------------------------------- |
| Id |
Install & use Install: follow the bundled instructions
- Unzip the archive from playbuff and read the bundled readme / instructions first.
- Most mods rely on the game's mod loader — the usual route is a community mod manager (such as r2modman): pick this game, install, and it handles the loader and dependencies.
- For a manual install, put the mod files into the matching Mod / plugins folder inside the game directory.
- Launch the game to confirm it loaded; mods with listed dependencies need those installed as well.
Install locations vary a lot between mods — the bundled readme is the most reliable guide.
Install these first, or the mod will not work: