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

# Сущности

Поиск игроков и мобов вокруг и данные о каждой сущности.

`entities()` ищет сущности вокруг игрока: других игроков, мобов и всё остальное. Каждая сущность возвращается в обёртке `Entity`.

Обёртка хранит только сетевой id сущности, а Quick находит сущность по этому id заново при каждом обращении. Поэтому данные всегда актуальны. Если сущность пропала из мира, `valid()` возвращает `false`, а все геттеры возвращают нули.

```java
for (Entity entity : entities().players(16.0)) {
    if (!entity.self() && !entity.friend()) {
        render.entityBox(entity, 0xFFFF3B30, true);
    }
}

Entity target = entities().target();
if (target != null && target.distance() < 4.0) {
    interaction().attack(target);
}
```

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

* Первый цикл обводит красным боксом всех игроков в радиусе 16 блоков, кроме себя и друзей.
* Затем берётся цель боевых модулей, и если она ближе 4 блоков, по ней наносится удар.

## Entities

| Метод            | Тип        | Описание                                                                              |
| ---------------- | ---------- | ------------------------------------------------------------------------------------- |
| `of(id)`         | `Entity`   | обёртка по сетевому id; если такой сущности нет, `valid()` вернёт `false`             |
| `all(range)`     | `Entity[]` | все сущности в радиусе, ближние в начале                                              |
| `players(range)` | `Entity[]` | игроки, кроме себя                                                                    |
| `living(range)`  | `Entity[]` | все живые сущности, кроме себя                                                        |
| `target()`       | `Entity`   | цель боевых модулей: по ней бьёт аура, её показывает TargetHud; `null`, если цели нет |
| `crosshair()`    | `Entity`   | сущность под прицелом или `null`                                                      |

Массивы собираются заново при каждом вызове. При отрисовке лучше получить их один раз за кадр и дальше работать с сохранённой переменной.

## Entity

| Метод                                                                              | Тип       | Описание                                                                                                                |
| ---------------------------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------- |
| `id()`                                                                             | `int`     | сетевой id                                                                                                              |
| `valid()`                                                                          | `boolean` | есть ли сущность в мире прямо сейчас                                                                                    |
| `name()`                                                                           | `String`  | имя без цветов и форматирования                                                                                         |
| `displayName()`                                                                    | `Text`    | имя с цветом команды и префиксами, рисуется по частям                                                                   |
| `type()`                                                                           | `String`  | тип, например `"minecraft:zombie"`                                                                                      |
| `uuid()`                                                                           | `String`  | uuid с дефисами                                                                                                         |
| `skin()`                                                                           | `String`  | путь к текстуре скина; пока скин не загрузился, возвращается Стив или Алекс                                             |
| `x()`, `y()`, `z()`                                                                | `double`  | позиция; `y` по низу хитбокса                                                                                           |
| `position()`                                                                       | `Point`   | то же одной точкой                                                                                                      |
| `position(delta)`                                                                  | `Point`   | плавная позиция для отрисовки                                                                                           |
| `motion()`                                                                         | `Point`   | скорость                                                                                                                |
| `yaw()`, `pitch()`                                                                 | `float`   | куда повёрнута голова                                                                                                   |
| `width()`, `height()`                                                              | `float`   | размеры хитбокса                                                                                                        |
| `distance()`                                                                       | `double`  | расстояние до своего игрока                                                                                             |
| `health()`                                                                         | `float`   | здоровье в том виде, в каком его видит Quick; если включён модуль чтения здоровья со скорборда, значение берётся оттуда |
| `maxHealth()`, `absorption()`                                                      | `float`   | максимум здоровья и золотые сердца                                                                                      |
| `hurtTime()`                                                                       | `int`     | сколько тиков ещё идёт анимация получения урона                                                                         |
| `alive()`                                                                          | `boolean` | жива ли сущность                                                                                                        |
| `player()`, `living()`                                                             | `boolean` | игрок ли это, живая ли это сущность                                                                                     |
| `self()`                                                                           | `boolean` | это свой игрок                                                                                                          |
| `friend()`                                                                         | `boolean` | есть в списке друзей Quick                                                                                              |
| `sneaking()`, `sprinting()`, `onGround()`, `invisible()`, `inWater()`, `gliding()` | `boolean` | что сущность делает сейчас                                                                                              |
| `held()`, `offhand()`                                                              | `Item`    | что в руках                                                                                                             |
| `armor(part)`                                                                      | `Item`    | броня: `Entity.HEAD`, `CHEST`, `LEGS`, `FEET`                                                                           |

`equals` и `hashCode` сравнивают обёртки по id, поэтому их можно класть в `Set` и `Map`.

У `Script` также есть старый метод `target()`. Он возвращает ванильный объект с типом `Object`, а классы игры скриптам недоступны, поэтому использовать его не получится. Вместо него используйте `entities().target()`.


---

# 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/game/entities.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.
