Skip to content

HitResults ​

Lets scripts distinguish block and entity targeting results through the HitResults global.
Block includes misses; use isMissed() to distinguish them.

js
const interactions = Player.interactions();  
const hit = interactions === null ? null : interactions.getTarget();  
if (hit instanceof HitResults.Entity) {
 Chat.log(hit.getEntity().getName());  
}

These names are available in JavaScript and Python without importing anything. They are read-only aliases of Java types, so instanceof works as usual.

Script nameWhat it is
HitResults.BlockRepresents a block hit or miss; use isMissed() to distinguish them.
HitResults.EntityA target that carries the entity and the hit location recorded by the hit result.
HitResults.ResultWraps a crosshair hit result, with shared access to its hit position and subtype-specific access for block and entity hits.