API reference / @jsprismarine/entity-brains / Behavior
Class: Behavior
Defined in: behavior/control.ts:79
A behavior with memory preconditions and a duration. Java's abstract Behavior.
tryStart draws a duration uniformly from [minDuration, maxDuration] and records when the behavior times out. canStillUse returns false by default, so a behavior that does not override it runs for exactly one tick.
Implements
Constructors
Constructor
new Behavior(
name,entryCondition,hooks?,duration?):Behavior
Defined in: behavior/control.ts:90
Parameters
name
string
entryCondition
hooks?
BehaviorHooks = {}
duration?
Partial<BehaviorDuration> = {}
Returns
Behavior
Properties
name
readonlyname:string
Defined in: behavior/control.ts:80
The Java class name, which is what a debug read-out shows.
Implementation of
Accessors
requiredMemories
Get Signature
get requiredMemories(): readonly
MemoryModuleType<unknown>[]
Defined in: behavior/control.ts:107
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.
Returns
readonly MemoryModuleType<unknown>[]
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
status
Get Signature
get status():
BehaviorStatus
Defined in: behavior/control.ts:103
Returns
Implementation of
Methods
doStop()
doStop(
context,timestamp):void
Defined in: behavior/control.ts:133
Marks the behavior stopped and runs the stop hook.
Parameters
context
timestamp
number
Returns
void
Implementation of
tickOrStop()
tickOrStop(
context,timestamp):void
Defined in: behavior/control.ts:124
Runs the tick hook while the behavior has time left and canStillUse holds, and stops it otherwise.
Parameters
context
timestamp
number
Returns
void
Implementation of
tryStart()
tryStart(
context,timestamp):boolean
Defined in: behavior/control.ts:112
Checks the memory conditions and checkExtraStartConditions, then draws how long this run lasts.
Parameters
context
timestamp
number
Returns
boolean