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

# Взаимодействие

Удары, использование предметов и работа с блоками.

Методы `interaction()` нужны, когда скрипт должен ударить сущность, использовать предмет или сломать блок.

```java
Entity target = entities().target();
if (target != null) {
    Point point = interaction().attackPoint(target, "multi", 4.5, false);
    if (point != null) {
        rotations().apply(rotations().lookAt(point));
        interaction().attack(target);
    }
}
```

## Как это работает

Скрипт берёт цель и ищет на её хитбоксе точку, до которой можно дотянуться на 4.5 блока, не через стены. Если такая точка есть, скрипт поворачивается к ней и бьёт.

## Удары и использование

| Метод                                                  | Тип       | Описание                                                              |
| ------------------------------------------------------ | --------- | --------------------------------------------------------------------- |
| `attack(entity)`                                       | `boolean` | ударить сущность, рука тоже взмахнёт                                  |
| `attackCrosshair()`                                    | `boolean` | обычный удар по тому, что под прицелом, как в ванильной игре          |
| `attackCooldown()`                                     | `float`   | готовность удара от 0 до 1                                            |
| `attackPoint(entity)`                                  | `Point`   | ближайшая точка на хитбоксе цели или `null`                           |
| `attackPoint(entity, mode, maxDistance, throughWalls)` | `Point`   | точка для прицеливания в режиме `"nearest"`, `"center"` или `"multi"` |
| `useCrosshair(offhand)`                                | `boolean` | обычное использование того, что под прицелом, как в ванильной игре    |
| `useItem(offhand)`                                     | `boolean` | начать использовать предмет в руке                                    |
| `stopUsingItem()`                                      | `boolean` | перестать использовать предмет: выстрелить из лука, бросить трезубец  |
| `swapHands()`                                          | `boolean` | поменять предметы в руках местами                                     |
| `swing(offhand)`                                       | `boolean` | взмахнуть рукой, пакет тоже отправится                                |

`attack` не учитывает откат удара. Чтобы бить только при полной готовности, проверяйте `attackCooldown() >= 1f`.

## Блоки

| Метод                              | Тип       | Описание                                     |
| ---------------------------------- | --------- | -------------------------------------------- |
| `useBlock(x, y, z, side, offhand)` | `boolean` | взаимодействие с гранью блока                |
| `startBreaking(x, y, z, side)`     | `boolean` | начать ломать блок                           |
| `continueBreaking(x, y, z, side)`  | `boolean` | продолжить ломать; `true`, когда блок сломан |
| `stopBreaking()`                   | `boolean` | прекратить ломать                            |
| `breakingBlock()`                  | `boolean` | ломается ли блок сейчас                      |

Стороны: 0 низ, 1 верх, 2 север, 3 юг, 4 запад, 5 восток. Нумерация совпадает с той, что возвращает `world().raycastSide(distance)`, поэтому результат можно передавать напрямую.

Чтобы сломать блок, вызовите `startBreaking` один раз, затем вызывайте `continueBreaking` каждый тик, пока он не вернёт `true`. В креативе достаточно одного `startBreaking`, блок ломается сразу.

Выбор цели описан в [Сущностях](/game/entities.md), выбор слота в [Слотах и броне](/actions/slots.md), поворот в [Поворотах](/actions/rotations.md).


---

# 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/actions/interaction.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.
