> For the complete documentation index, see [llms.txt](https://docs.quickclient.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quickclient.cc/en/game/inventory.md).

# Inventory and items

Inventory slots, finding items and the properties of a single item.

`inventory()` shows what is in the player's inventory. You can use it to find a pearl, count apples or check an item's cooldown.

Slots are numbered the same way as in the game: `0..8` hotbar, `9..35` main inventory, `36..39` armor, `40` off hand. So you don't have to remember these numbers, there are constants: `Inventory.HOTBAR_END = 9`, `MAIN_END = 36`, `ARMOR_END = 40`, `OFFHAND = 40`, `SIZE = 41`.

```java
int pearls = inventory().findHotbar("ender_pearl");
if (pearls >= 0 && inventory().cooldown("ender_pearl") == 0f) {
    slots().using(pearls, () -> interaction().useItem(false));
}
```

In this example the script looks for a pearl in the hotbar and, if the cooldown is over, briefly takes it in hand and throws it.

## Inventory

| Method                | Type      | Description                                                              |
| --------------------- | --------- | ------------------------------------------------------------------------ |
| `slot(index)`         | `Item`    | item in slot `0..40`; an empty or nonexistent slot returns an empty item |
| `selected()`          | `int`     | which hotbar slot is selected right now                                  |
| `held()`, `offhand()` | `Item`    | what is in hand                                                          |
| `armor(part)`         | `Item`    | armor: `Entity.HEAD`, `CHEST`, `LEGS`, `FEET`                            |
| `find(id)`            | `int`     | first slot with that item or `-1`; the `minecraft:` prefix is optional   |
| `findHotbar(id)`      | `int`     | the same, but searches only the hotbar                                   |
| `count(id)`           | `int`     | how many of that item are in the whole inventory                         |
| `free()`              | `int`     | how many empty slots are in the main inventory                           |
| `cooldown(id)`        | `float`   | how many ticks are left on the cooldown that turns the item icon white   |
| `cooldown(item)`      | `float`   | the same, but by `Item`                                                  |
| `container()`         | `boolean` | a container is open rather than your own inventory                       |
| `containerId()`       | `int`     | number of the open window; `0` for your own inventory                    |

To switch the slot in hand or put on armor, use the methods from [Slots and armor](/en/actions/slots.md). Clicking in a chest is described in [Containers and screens](/en/game/containers.md).

## Item

An `Item` holds a copy of the item at the moment it was requested. If the item in the slot changes later, the copy stays the same.

| Method                    | Type       | Description                                                                                      |
| ------------------------- | ---------- | ------------------------------------------------------------------------------------------------ |
| `empty()`                 | `boolean`  | the slot is empty                                                                                |
| `id()`                    | `String`   | for example `"minecraft:diamond_sword"`                                                          |
| `key()`                   | `String`   | id without `minecraft:`                                                                          |
| `is(value)`               | `boolean`  | compare the id, the `minecraft:` prefix is optional                                              |
| `name()`                  | `String`   | name without colors or formatting                                                                |
| `renamed()`               | `boolean`  | the item has been renamed                                                                        |
| `count()`                 | `int`      | how many are in the stack                                                                        |
| `maxCount()`              | `int`      | how many fit in one slot                                                                         |
| `stackable()`             | `boolean`  | the item stacks                                                                                  |
| `damage()`, `maxDamage()` | `int`      | how much durability is used and how much there is in total; `0` for items that don't break       |
| `durability()`            | `float`    | how much durability is left, 0..1; `1` for items that don't break and for empty items            |
| `unbreakable()`           | `boolean`  | the item has the "unbreakable" tag                                                               |
| `food()`                  | `boolean`  | the item can be eaten; potions and milk are not included                                         |
| `tool()`                  | `boolean`  | pickaxe, axe, shovel, hoe, shears or sword                                                       |
| `armorPiece()`            | `boolean`  | goes into an armor slot                                                                          |
| `armor()`, `toughness()`  | `float`    | armor and armor toughness from attributes; `0` for other items                                   |
| `enchanted()`             | `boolean`  | has enchantments                                                                                 |
| `enchant(id)`             | `int`      | enchantment level or `0` if there is none; for a book, the enchantments stored on it are counted |
| `enchants()`              | `String[]` | ids of all enchantments                                                                          |
| `lore()`                  | `String[]` | lore lines without formatting                                                                    |

If the `Item` was obtained in the same tick, you can pass it straight to `Render2D.drawItem(item, …)`. Rendering finds the real item, so a head shows its skin, a potion its color, and a shulker box its contents.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.quickclient.cc/en/game/inventory.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
