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

# Interaction

Attacks, using items and working with blocks.

Use `interaction()` when your script needs to hit an entity, use an item or break a block.

```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);
    }
}
```

## How it works

The script takes the target and looks for a point on its hitbox that can be reached within 4.5 blocks, not through walls. If there is such a point, the script turns to it and attacks.

## Attacks and using items

| Method                                                 | Type      | Description                                                       |
| ------------------------------------------------------ | --------- | ----------------------------------------------------------------- |
| `attack(entity)`                                       | `boolean` | hit the entity, the hand swings too                               |
| `attackCrosshair()`                                    | `boolean` | a normal attack on whatever is under the crosshair, as in vanilla |
| `attackCooldown()`                                     | `float`   | attack readiness from 0 to 1                                      |
| `attackPoint(entity)`                                  | `Point`   | nearest point on the target's hitbox, or `null`                   |
| `attackPoint(entity, mode, maxDistance, throughWalls)` | `Point`   | point to aim at in `"nearest"`, `"center"` or `"multi"` mode      |
| `useCrosshair(offhand)`                                | `boolean` | normal use on whatever is under the crosshair, as in vanilla      |
| `useItem(offhand)`                                     | `boolean` | start using the item in hand                                      |
| `stopUsingItem()`                                      | `boolean` | stop using the item: shoot the bow, throw the trident             |
| `swapHands()`                                          | `boolean` | swap the items in your hands                                      |
| `swing(offhand)`                                       | `boolean` | swing the hand, the packet is sent too                            |

`attack` does not check the attack cooldown. To hit only at full charge, check `attackCooldown() >= 1f`.

## Blocks

| Method                             | Type      | Description                                        |
| ---------------------------------- | --------- | -------------------------------------------------- |
| `useBlock(x, y, z, side, offhand)` | `boolean` | interact with a block face                         |
| `startBreaking(x, y, z, side)`     | `boolean` | start breaking a block                             |
| `continueBreaking(x, y, z, side)`  | `boolean` | continue breaking; `true` once the block is broken |
| `stopBreaking()`                   | `boolean` | stop breaking                                      |
| `breakingBlock()`                  | `boolean` | whether a block is being broken right now          |

Sides: 0 down, 1 up, 2 north, 3 south, 4 west, 5 east. The numbering matches what `world().raycastSide(distance)` returns, so you can pass its result directly.

To break a block, call `startBreaking` once, then call `continueBreaking` every tick until it returns `true`. In creative a single `startBreaking` is enough, the block breaks right away.

Choosing a target is described in [Entities](/en/game/entities.md), choosing a slot in [Slots and armor](/en/actions/slots.md), turning in [Rotations](/en/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/en/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.
