Skip to content

HitResultHelper.Block ​

com.jsmacrosce.jsmacros.client.api.helper.world.HitResultHelper.Block

Since1.9.1

Represents a block hit or miss; use isMissed() to distinguish them.

js
const interactions = Player.interactions();  
const target = interactions === null ? null : interactions.getTarget();  
if (target instanceof HitResults.Block && !target.isMissed()) {
 const pos = target.getBlockPos();  
 if (pos !== null) Chat.log(`hit ${pos}`);  
}

Available in scripts as HitResults.Block.

Nested type declared in HitResultHelper.

Constructors ​

new HitResultHelper.Block ​

new HitResultHelper.Block(BlockHitResult base)#
Wraps the supplied block hit result, including a result representing a miss.

Parameters:

  • base: block hit result to wrap

Methods ​

asBlock ​

Returns this block-hit-or-miss helper.
Returns: this block-hit-or-miss helper

getBlockPos ​

getBlockPos(): BlockPosHelperSince1.9.1#
Returns the position carried by the block hit result. For a miss, this is the position supplied with that miss, not necessarily a block reached by the ray.
Returns: the block that was hit, or null if the hit carries no position.

getSide ​

getSide(): DirectionHelperSince1.9.1#
Returns the hit direction, or null if the result has no direction. Miss results also carry a direction; this does not imply a block was hit.
Returns: the face the ray came in on, or null if the hit carries no direction.

isInsideBlock ​

isInsideBlock(): booleanSince1.9.1#
Whether the underlying block hit is marked as inside; this is independent of whether the hit is a miss.
Returns: true if the hit is marked as inside.

isMissed ​

isMissed(): booleanSince1.9.1#
Returns whether this block hit result is marked as a miss.
Returns: true if this hit is a miss rather than a block that was reached.

toString ​

toString(): String#
Returns a diagnostic containing the hit position, direction, block position, miss flag, and inside flag.
Returns: a diagnostic with those values rendered from the underlying result and helper accessors