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 name | What it is |
|---|---|
HitResults.Block | Represents a block hit or miss; use isMissed() to distinguish them. |
HitResults.Entity | A target that carries the entity and the hit location recorded by the hit result. |
HitResults.Result | Wraps a crosshair hit result, with shared access to its hit position and subtype-specific access for block and entity hits. |