Appearance
spool / RaycastOptions
Interface: RaycastOptions
Defined in: plugins/raycast/index.ts:23
A reusable block raycast: the classic datapack ray that marches the local forward axis (^) through air until it hits a block (or runs out of reach), then runs a caller-supplied body at the hit position. It's pure command math - no entities, no macros - and inlines into the consuming pack's own namespace under raycast/<name>.
The plugin is un-opinionated about what a hit means: you pass an onHit callback (summon a marker, place a block, read the position - whatever), and an optional hitOn filter so only certain blocks count as a hit. grapple is the first consumer (its web anchor), but nothing here is grapple-specific.
Split by concern: context.ts (the shared raycast.work state + load-init), march.ts (the recursive marcher). This file is the public type + plugin.
Properties
hitOn?
readonlyoptionalhitOn?:BlockValue
Defined in: plugins/raycast/index.ts:39
Restrict what counts as a hit (a block id, or a tag via Block.tag("logs")). The ray still stops at the first non-air block; if that block doesn't match, onHit simply doesn't fire (a clean miss). Default: any non-air block is a hit.
maxSteps
readonlymaxSteps:number
Defined in: plugins/raycast/index.ts:31
Maximum reach, in steps (each step is stepBlocks along ^).
name
readonlyname:string
Defined in: plugins/raycast/index.ts:29
The marcher's function path suffix and step-slot name - registers raycast/<name> and counts steps on #<name>_steps. Must be unique per pack; pick a stable, feature-scoped name (e.g. "grapple/web").
stepBlocks?
readonlyoptionalstepBlocks?:number
Defined in: plugins/raycast/index.ts:33
Stride per step along the line of sight, in blocks. Default 0.5.
Methods
onHit()
onHit(
ctx):void
Defined in: plugins/raycast/index.ts:44
What to do at the hit. Runs positioned at the hit block (and, with hitOn, only when it matches), building commands into the marcher's on-hit branch.
Parameters
ctx
FunctionContext
Returns
void