# InteractionProxy.Target

`com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target`

Manages the shared client-side crosshair-target override maintained by client hooks; it is not
 per-player and does not grant server reach. Scripts normally use the player's interaction
 manager:  
 ```js
const interactions = Player.getInteractionManager();  
if (interactions !== null) {
  if (interactions.hasTargetOverride()) {
    interactions.clearTargetOverride();  
  }
}
 ```

 Target checks may clear an override or render a miss while retaining the stored target.  
 Clearing it can end a pending break override and run callbacks on the caller's thread.

Nested type declared in [InteractionProxy](InteractionProxy.md).

## Constructors

### new InteractionProxy.Target {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_constructor-}

```js
new InteractionProxy.Target()
```

## Fields

### checkAir {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_checkAir}

```js
static checkAir: boolean
```

Enables checking whether a block target's state is air during target updates; defaults to false.

### checkDistance {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_checkDistance}

```js
static checkDistance: boolean
```

Enables the interaction-range check during target updates; defaults to true. Assignment alone does not recheck a target.

### checkShape {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_checkShape}

```js
static checkShape: boolean
```

Enables checking whether a non-air block target has an empty block shape during target updates; defaults to true.

### clearIfEmptyShape {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_clearIfEmptyShape}

```js
static clearIfEmptyShape: boolean
```

When shape checking is enabled, clears an empty-shape target if true; otherwise an update renders a miss but retains it. Defaults to false.

### clearIfIsAir {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_clearIfIsAir}

```js
static clearIfIsAir: boolean
```

When air checking is enabled, clears an air-block target if true; otherwise an update renders a miss but retains it. Defaults to false.

### clearIfOutOfRange {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_clearIfOutOfRange}

```js
static clearIfOutOfRange: boolean
```

When distance checking is enabled, clears an out-of-range target if true; otherwise an update renders a miss but retains it. Defaults to true.

## Methods

### hasOverride {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_hasOverride-}

```js
static hasOverride(): boolean
```

Reports whether a target override is stored, including a miss or a target currently rendered
 as a miss by checks. Does not revalidate the target or query the current crosshair hit.

**Returns:** whether a target override is present

### isInRange {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_isInRange-float-}

```js
static isInRange(float tickDelta): boolean
```

Tests the stored target against client interaction reach, independently of `checkDistance`.  
 Without a stored target, player or game mode this returns false; a miss otherwise passes.  
 A hit location must be strictly within the entity or block reach as appropriate; block targets
 also pass when the nearest point on their unit block cube is strictly within block reach.  
 This does not check air, shape or visibility, clear the target, or confirm server permission.

**Parameters:**
- `tickDelta`: interpolation fraction for the player's eye position

**Returns:** whether the stored target passes the client distance calculation

### onUpdate {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_onUpdate-float-}

```js
static onUpdate(float tickDelta): boolean
```

Applies the stored target to the crosshair state after configured checks. A false result can still
 follow clearing a dead or invalid target; a block check without a level leaves it stored and unapplied.  
 Clearing can end a pending break override and invoke callbacks on this caller's thread.

**Parameters:**
- `tickDelta`: interpolation fraction used for the range check

**Returns:** whether the override or a miss was applied, so the normal crosshair pick should be skipped

### resetChecks {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_resetChecks-}

```js
static resetChecks(): void
```

Restores range checking and out-of-range clearing to true, air checking and air clearing to false, and shape checking to true with empty-shape clearing false. Does not clear or immediately revalidate the target.

### setTarget {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_setTarget-HitResult-}

```js
static setTarget(HitResult value): void
```

Stores the supplied target reference and immediately applies the current checks and break-state
 update at interpolation fraction zero. A check may clear it or render a miss while retaining it.  
 Break revalidation can end a pending break override and run callbacks on the caller's thread,  
 even for a non-null target. Clearing does not itself restore a normal crosshair raycast.

**Parameters:**
- `value`: target override, or null to clear it

### setTargetBlock {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_setTargetBlock-BlockPos-Direction-}

```js
static setTargetBlock(BlockPos pos, Direction direction): void
```

Sets a block target at the block's center; a null position clears the target. The direction
 is used only for a non-null position. Delegates to `setTarget`, including immediate
 checks and break revalidation that can end a pending break override and run callbacks on the caller's thread.

**Parameters:**
- `pos`: block position, or null to clear the target
- `direction`: face recorded in the constructed block hit result; ignored when `pos` is null

### setTargetMissed {#com.jsmacrosce.jsmacros.client.api.classes.InteractionProxy.Target_setTargetMissed-}

```js
static setTargetMissed(): void
```

Sets the fixed miss result through `setTarget`; it does not request clearing the override.  
 The same checks and break revalidation apply and can run break callbacks on the caller's thread.
