> 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/containers.md).

# Containers and screens

Reading and clicking in an open container and checking the current screen.

`container()` is used when a chest, ender chest, furnace or server menu is open: it lets you see the contents and click the slots. The player's own inventory is not a container, so for it `open()` returns `false`.

```java
if (container().open() && container().title().contains("Chest")) {
    int slot = container().find("ender_pearl");
    if (slot >= 0) container().shiftClick(slot);
}
```

Here the script checks that a chest is open, looks for a pearl in it and moves it to the inventory with a shift-click.

Slots in the window are numbered like this: first come the container's own slots, `0..size()-1`, and after them, in the same window, the player's inventory. `slot(index)` does not show the player's inventory, but you can still click on it. So moving an item into a chest is simple: shift-click its number in the window.

## Reading

| Method          | Type      | Description                                                              |
| --------------- | --------- | ------------------------------------------------------------------------ |
| `open()`        | `boolean` | a container is open rather than your own inventory                       |
| `id()`          | `int`     | window number as the server knows it; `0` if nothing is open             |
| `size()`        | `int`     | how many slots the container itself has, without the player's inventory  |
| `title()`       | `String`  | title without formatting                                                 |
| `type()`        | `String`  | menu type, for example `"minecraft:generic_9x6"`                         |
| `slot(index)`   | `Item`    | item in a container slot; an empty or invalid slot returns an empty item |
| `find(itemId)`  | `int`     | first slot with that item or `-1`                                        |
| `count(itemId)` | `int`     | how many of that item there are in total                                 |

## Clicks

Clicks are not performed instantly. They go into Quick's shared queue, so they don't interfere with other modules. Each method returns `true` if the click was added to the queue.

| Method                | Type      | Description                                                     |
| --------------------- | --------- | --------------------------------------------------------------- |
| `click(slot, button)` | `boolean` | regular click: `0` left button, `1` right                       |
| `shiftClick(slot)`    | `boolean` | move a stack from the container to the inventory or back        |
| `swap(slot, hotbar)`  | `boolean` | swap with hotbar slot `0..8` or with `Container.OFFHAND`        |
| `drop(slot)`          | `boolean` | drop the stack                                                  |
| `close()`             | `boolean` | close the window after the clicks already in the queue are done |

To click your own inventory inside the window, use the number `size() + index`. The easiest way is to find the item with `inventory().find(id)` and add this offset to the result.

A complete script is available in the [Chest to inventory](/en/examples/chest-taker.md) example.

## Screens

A screen is anything open on top of the game: chat, inventory, a container, the Quick menu or any other window. In input events the screen is available through `event.screen()`, and everywhere else through `client().screen()`.

| Method                                           | Type      | Description                                                      |
| ------------------------------------------------ | --------- | ---------------------------------------------------------------- |
| `open()`                                         | `boolean` | whether any screen is open                                       |
| `kind()`                                         | `int`     | `Screen.NONE`, `CHAT`, `INVENTORY`, `CONTAINER`, `MENU`, `OTHER` |
| `chat()`, `inventory()`, `container()`, `menu()` | `boolean` | quick checks                                                     |
| `type()`                                         | `String`  | short class name, for example `"ChatScreen"`                     |
| `title()`                                        | `String`  | title without formatting                                         |
| `is(name)`                                       | `boolean` | whether the class name contains the string, case-insensitive     |

When a screen opens or closes, a `ScreenEvent` is fired. Subscribing to it is described in [Subscribing to events](/en/events/basics.md). To find out whether the player is typing in chat or a text field right now, use `keys().inputBlocked()`.


---

# 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/containers.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.
