Skip to content

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 ​

Trigger

Returns ​

OneShot

Properties ​

name ​

readonly name: string

Defined in: behavior/control.ts:166

The Java class name, which is what a debug read-out shows.

Implementation of ​

BehaviorControl.name


requiredMemories ​

readonly requiredMemories: readonly MemoryModuleType<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 ​

BehaviorStatus

Implementation of ​

BehaviorControl.status

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 ​

BrainContext

_timestamp ​

number

Returns ​

void

Implementation of ​

BehaviorControl.doStop


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 ​

BrainContext

timestamp ​

number

Returns ​

void

Implementation of ​

BehaviorControl.tickOrStop


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 ​

BrainContext

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 ​

BrainContext

timestamp ​

number

Returns ​

boolean

Implementation of ​

BehaviorControl.tryStart