HitResultHelper.Block
com.jsmacrosce.jsmacros.client.api.helper.world.HitResultHelper.Block
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
asBlock(): HitResultHelper.Block#Returns this block-hit-or-miss helper.
Returns: this block-hit-or-miss helper
getBlockPos
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
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
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
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.