# InteractBlock

`com.jsmacrosce.jsmacros.client.api.event.impl.player.EventInteractBlock`

**Since:** 1.8.0

**Cancellable:** No. Calling `event.cancel()` throws `UnsupportedOperationException`.

Fires after a local block-use attempt returns, unless the result is `FAIL`. [result](#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventInteractBlock_result)
is true when the interaction consumes an action; false means
it was passed along without consuming one, not that it failed.  
```js
JsMacros.on("InteractBlock", JavaWrapper.methodToJava(function (event) {
  if (event.result) {
    Chat.log(`${event.offhand ? "Off hand" : "Main hand"} used on ${event.block.getId()}`);  
  }
}))
```

## Constructors

### new EventInteractBlock {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventInteractBlock_constructor-boolean-boolean-BlockDataHelper-int-}

```js
new EventInteractBlock(boolean offhand, boolean accepted, BlockDataHelper block, int side)
```

Stores the supplied block-interaction data and initializes the event with the client core.

**Parameters:**
- `offhand`: whether the supplied hand flag identifies the off hand; `false` identifies the main hand
- `accepted`: supplied action-consumption flag, stored as `result`
- `block`: the supplied block helper reference
- `side`: the supplied hit-face code

## Fields

### block {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventInteractBlock_block}

```js
block: BlockDataHelper
```

The clicked block as seen by the client, including its block entity when present.

### offhand {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventInteractBlock_offhand}

```js
offhand: boolean
```

`true` if the click was made with the off hand, `false` if it was made with the
main hand.

### result {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventInteractBlock_result}

```js
result: boolean
```

`true` when the interaction consumes an action; `false` when it passes without
consuming one. This event is not fired for a `FAIL` result.

### side {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventInteractBlock_side}

```js
side: int
```

The clicked face's numeric direction id:  
`0` down, `1` up, `2` north, `3` south, `4` west and
`5` east.

## Methods

### toString {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventInteractBlock_toString-}

```js
toString(): String
```

Returns this event's formatted string representation.  
The payload has the form `eventName:{"block": helper, "result": "boolean"}`; the
boolean value is quoted, and the offhand and side values are omitted. This is not JSON.

**Returns:** the event-name-prefixed representation containing the block helper and stored result
