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

# Лучи и прицел

Как узнать блок, его сторону и сущность под прицелом.

На этой странице собраны методы, которые помогают понять, куда смотрит игрок: на какой блок, на какую его сторону и на какую сущность.

```java
Block looking = world().raycastBlock(5.0);
if (looking != null && looking.is("chest")) {
    chat("Сундук на " + looking.x() + " " + looking.y() + " " + looking.z());
}

Entity aimed = entities().crosshair();
if (aimed != null) chat("На прицеле " + aimed.name());
```

## Блоки

| Метод                                     | Тип     | Описание                                                           |
| ----------------------------------------- | ------- | ------------------------------------------------------------------ |
| `world().raycastBlock(distance)`          | `Block` | первый блок на луче от глаз или `null`                             |
| `world().raycastBlock(distance, liquids)` | `Block` | то же, но можно указать, останавливают ли луч вода и лава          |
| `world().raycastSide(distance)`           | `int`   | в какую сторону блока попал луч; `-1`, если луч ни во что не попал |

Номера сторон: 0 низ, 1 верх, 2 север, 3 юг, 4 запад, 5 восток. Те же номера принимают `interaction().useBlock` и `startBreaking`, см. [Взаимодействие](/actions/interaction.md).

## Сущности

| Метод                                                                | Тип      | Описание                               |
| -------------------------------------------------------------------- | -------- | -------------------------------------- |
| `entities().crosshair()`                                             | `Entity` | сущность под прицелом или `null`       |
| `interaction().attackPoint(entity)`                                  | `Point`  | ближайшая к игроку точка хитбокса цели |
| `interaction().attackPoint(entity, mode, maxDistance, throughWalls)` | `Point`  | точка с учётом режима и стен           |

`attackPoint` не пускает луч от глаз, а ищет на хитбоксе точку, в которую действительно можно попасть. Режим `"nearest"` берёт ближайшую точку, `"center"` центр, а `"multi"` перебирает несколько точек и проверяет, не закрывают ли их стены. Если попасть некуда, возвращается `null`.

## Угол до точки

`rotations().angleTo(x, y, z)` возвращает, на сколько градусов направление взгляда отличается от направления на точку, от 0 до 180. Это пригодится, когда нужно только проверить, смотрит ли игрок примерно в нужную сторону, без лучей. Подробнее на странице [Повороты](/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/game/raycast.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.
