API reference / @jsprismarine/entity-brains / OneShot
Class: OneShot
Defined in: behavior/control.ts:165
A behavior whose whole body is one Trigger. Java's OneShot.
It is running for exactly the tick in which it fired: tickOrStop stops it unconditionally.
Implements
Constructors
Constructor
new OneShot(
name,requiredMemories,body):OneShot
Defined in: behavior/control.ts:172
Parameters
name
string
requiredMemories
readonly MemoryModuleType<unknown>[]
body
Returns
OneShot
Properties
name
readonlyname:string
Defined in: behavior/control.ts:166
The Java class name, which is what a debug read-out shows.
Implementation of
requiredMemories
readonlyrequiredMemories: readonlyMemoryModuleType<unknown>[]
Defined in: behavior/control.ts:167
Every memory the behavior reads or writes. The brain registers each one when the behavior is added, which is how a memory a mob never declares still gets a slot.
Implementation of
BehaviorControl.requiredMemories
Accessors
status
Get Signature
get status():
BehaviorStatus
Defined in: behavior/control.ts:178
Returns
Implementation of
Methods
doStop()
doStop(
_context,_timestamp):void
Defined in: behavior/control.ts:202
Marks the one-shot stopped. It holds no state beyond its status.
Parameters
_context
_timestamp
number
Returns
void
Implementation of
tickOrStop()
tickOrStop(
context,timestamp):void
Defined in: behavior/control.ts:197
Stops at once: a one-shot never survives into a second tick.
Parameters
context
timestamp
number
Returns
void
Implementation of
trigger()
trigger(
context,timestamp):boolean
Defined in: behavior/control.ts:183
Runs the body without touching the status, which is what GateBehavior composes.
Parameters
context
timestamp
number
Returns
boolean
tryStart()
tryStart(
context,timestamp):boolean
Defined in: behavior/control.ts:188
Runs the body once. The one-shot counts as started only when the body reports it did something.
Parameters
context
timestamp
number
Returns
boolean