Skip to content

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.

Constructors ​

new InteractionProxy.Target ​

new InteractionProxy.Target()#

Fields ​

checkAir ​

static checkAir: boolean#
Enables checking whether a block target's state is air during target updates; defaults to false.

checkDistance ​

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

checkShape ​

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

clearIfEmptyShape ​

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 ​

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 ​

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 ​

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 ​

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 ​

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 ​

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 ​

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 ​

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 ​

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.