====== cInventory class ======
This object is used to store the items that a [[API:cPlayer|cPlayer]] has. It also keeps track of what item the player has currently selected in their hotbar.
Internally, the class uses three [[API:cItemGrid|cItemGrid]] objects to store the contents:
  * Armor
  * Inventory
  * Hotbar
These ItemGrids are available in the API and can be manipulated by the plugins, too.

===== Constants =====
When using the raw slot access functions, such as GetSlot() and SetSlot(), the slots are numbered consecutively, each ItemGrid has its offset and count. To future-proff your plugins, use the following constants instead of hard-coded numbers:
^ Constant ^ Value ^ Description ^
| invArmorCount | 4 | Number of slots in the armor ItemGrid |
| invArmorOffset | 0 | Starting slotnumber for the armor ItemGrid |
| invInventoryCount | 27 | Number of slots in the main inventory ItemGrid |
| invInventoryOffset | 4 | Starting slotnumber for the main inventory ItemGrid |
| invHotbarCount | 9 | Number of slots in the hotbar |
| invHotbarOffset | 31 | Starting slotnumber for the hotbar |
| invNumSlots | 40 | Total number of slots in the cInventory object |

===== Functions =====
^ Function ^ Parameters ^ Return type ^ Notes ^
| AddItem | [[API:cItem|cItem]], [AllowNewStacks] | number | Adds an item to the storage; if AllowNewStacks is true (default), will also create new stacks in empty slots. Returns the number of items added |
| AddItems | [[API:cItems|cItems]], [AllowNewStacks] | number | Same as AddItem, but for several items at once |
| ChangeSlotCount | SlotNum, AddToCount | number | Adds AddToCount to the count of items in the specified slot. If the slot was empty, ignores the call. Returns the new count in the slot, or -1 if invalid SlotNum |
| Clear | | | Empties all slots |
| CopyToItems | [[API:cItems|cItems]] | | Copies all non-empty slots into the cItems object provided; original cItems contents are preserved |
| DamageEquippedItem | [DamageAmount] | bool | Adds the specified damage (1 by default) to the currently equipped item
| DamageItem | SlotNum, [DamageAmount] | bool | Adds the specified damage (1 by default) to the specified item, returns true if the item reached its max damage and should be destroyed |
| GetArmorGrid | | [[API:cItemGrid|cItemGrid]] | Returns the ItemGrid representing the armor grid (1 x 4 slots) |
| GetArmorSlot | ArmorSlotNum | [[API:cItem|cItem]] | Returns the specified armor slot contents. Note that the returned item is read-only |
| GetEquippedBoots | | [[API:cItem|cItem]] | Returns the item in the "boots" slot of the armor grid. Note that the returned item is read-only |
| GetEquippedChestplate | | [[API:cItem|cItem]] | Returns the item in the "chestplate" slot of the armor grid. Note that the returned item is read-only |
| GetEquippedHelmet | | [[API:cItem|cItem]] | Returns the item in the "helmet" slot of the armor grid. Note that the returned item is read-only |
| GetEquippedItem | | [[API:cItem|cItem]] | Returns the currently selected item from the hotbar. Note that the returned item is read-only |
| GetEquippedLeggings | | [[API:cItem|cItem]] | Returns the item in the "leggings" slot of the armor grid. Note that the returned item is read-only |
| GetEquippedSlotNum | | number | Returns the hotbar slot number for the currently selected item |
| GetHotbarGrid | | [[API:cItemGrid|cItemGrid]] | Returns the ItemGrid representing the hotbar grid (9 x 1 slots) |
| GetHotbarSlot | HotBarSlotNum | [[API:cItem|cItem]] | Returns the specified hotbar slot contents. Note that the returned item is read-only |
| GetInventoryGrid | | [[API:cItemGrid|cItemGrid]] | Returns the ItemGrid representing the main inventory (9 x 3 slots) |
| GetInventorySlot | InventorySlotNum | [[API:cItem|cItem]] | Returns the specified main inventory slot contents. Note that the returned item is read-only |
| GetOwner | | [[API:cPlayer|cPlayer]] | Returns the player whose inventory this object represents |
| GetSlot | SlotNum | [[API:cItem|cItem]] | Returns the contents of the specified slot. Note that the returned item is read-only |
| HasItems | [[API:cItem|cItem]] | bool | Returns true if there are at least as many items of the specified type as in the parameter |
| HowManyCanFit | [[API:cItem|cItem]] | number | Returns the number of the specified items that can fit in the storage, including empty slots |
| HowManyItems | [[API:cItem|cItem]] | number | Returns the number of the specified items that are currently stored |
| RemoveOneEquippedItem | | | Removes one item from the hotbar's currently selected slot |
| SetArmorSlot | ArmorSlotNum, [[API:cItem|cItem]] | | Sets the specified armor slot contents |
| SetEquippedSlotNum | EquippedSlotNum | | Sets the currently selected hotbar slot number |
| SetHotbarSlot | HotbarSlotNum, [[API:cItem|cItem]] | | Sets the specified hotbar slot contents |
| SetInventorySlot | InventorySlotNum, [[API:cItem|cItem]] | | Sets the specified main inventory slot contents |
| SetSlot | SlotNum, [[API:cItem|cItem]] | | Sets the specified slot contents |
