API reference / @jsprismarine/client
@jsprismarine/client
Enumerations
LoginStage
Defined in: client/src/login/LoginSequence.ts:27
How far a login has got. Every step is driven by a packet, never by a timer.
Enumeration Members
AUTHENTICATING
AUTHENTICATING:
1
Defined in: client/src/login/LoginSequence.ts:29
AWAITING_SPAWN
AWAITING_SPAWN:
3
Defined in: client/src/login/LoginSequence.ts:31
FAILED
FAILED:
5
Defined in: client/src/login/LoginSequence.ts:33
NEGOTIATING_RESOURCE_PACKS
NEGOTIATING_RESOURCE_PACKS:
2
Defined in: client/src/login/LoginSequence.ts:30
REQUESTING_NETWORK_SETTINGS
REQUESTING_NETWORK_SETTINGS:
0
Defined in: client/src/login/LoginSequence.ts:28
SPAWNED
SPAWNED:
4
Defined in: client/src/login/LoginSequence.ts:32
SendPriority
Defined in: client/src/net/ITransport.ts:2
How urgently a payload should leave. Mirrors RakNet's own two levels.
Enumeration Members
IMMEDIATE
IMMEDIATE:
1
Defined in: client/src/net/ITransport.ts:4
NORMAL
NORMAL:
0
Defined in: client/src/net/ITransport.ts:3
Classes
- Bot
- BreakBehavior
- ChatBehavior
- Client
- ClientPacketRegistry
- ClientSession
- DimensionChange
- Fleet
- LoginSequence
- LookBehavior
- RakNetTransport
- Random
- Samples
- WalkBehavior
Interfaces
Behavior
Defined in: client/src/bot/behavior/Behavior.ts:27
Something a bot does, once per tick.
Small and composable on purpose: a load test is a question, and the question is usually about one kind of traffic. "Two hundred clients walking" and "two hundred clients chatting" load a server very differently, and being able to ask them separately is worth more than a single realistic-looking simulation that mixes everything.
A behavior must never throw for a reason it could have checked - a bot that dies takes its connection out of the fleet and quietly changes what is being measured.
Properties
name
readonlyname:string
Defined in: client/src/bot/behavior/Behavior.ts:28
Methods
tick()
tick(
context):void|Promise<void>
Defined in: client/src/bot/behavior/Behavior.ts:31
Called on every tick of the bot that owns it.
Parameters
context
Returns
void | Promise<void>
BehaviorContext
Defined in: client/src/bot/behavior/Behavior.ts:5
Properties
bot
readonlybot:Bot
Defined in: client/src/bot/behavior/Behavior.ts:6
random
readonlyrandom:Random
Defined in: client/src/bot/behavior/Behavior.ts:8
This bot's own generator, derived from the fleet seed and its index.
tick
readonlytick:number
Defined in: client/src/bot/behavior/Behavior.ts:10
How many times this bot has ticked since it spawned.
Methods
record()
record(
action):void
Defined in: client/src/bot/behavior/Behavior.ts:13
Counted into the report, so a run can say what it actually did.
Parameters
action
string
Returns
void
send()
send(
packet):Promise<void>
Defined in: client/src/bot/behavior/Behavior.ts:11
Parameters
packet
NetworkPacket<any>
Returns
Promise<void>
BotOptions
Defined in: client/src/bot/Bot.ts:14
Properties
behaviors
readonlybehaviors: readonlyBehavior[]
Defined in: client/src/bot/Bot.ts:20
displayName
readonlydisplayName:string
Defined in: client/src/bot/Bot.ts:19
host
readonlyhost:string
Defined in: client/src/bot/Bot.ts:15
logger
readonlylogger:Logger
Defined in: client/src/bot/Bot.ts:22
loginTimeoutMs?
readonlyoptionalloginTimeoutMs?:number
Defined in: client/src/bot/Bot.ts:24
network?
readonlyoptionalnetwork?:"raknet"|"nethernet"
Defined in: client/src/bot/Bot.ts:18
Which transport to dial; RakNet by default.
port
readonlyport:number
Defined in: client/src/bot/Bot.ts:16
random
readonlyrandom:Random
Defined in: client/src/bot/Bot.ts:21
viewDistance
readonlyviewDistance:number
Defined in: client/src/bot/Bot.ts:23
ClientOptions
Defined in: client/src/Client.ts:60
Properties
auth?
readonlyoptionalauth?:IAuthProvider
Defined in: client/src/Client.ts:65
displayName?
readonlyoptionaldisplayName?:string
Defined in: client/src/Client.ts:64
Defaults to an offline identity under this name.
host
readonlyhost:string
Defined in: client/src/Client.ts:61
logger?
readonlyoptionallogger?:Logger
Defined in: client/src/Client.ts:66
loginTimeoutMs?
readonlyoptionalloginTimeoutMs?:number
Defined in: client/src/Client.ts:74
network?
readonlyoptionalnetwork?:"raknet"|"nethernet"
Defined in: client/src/Client.ts:73
Which transport to dial when no ClientOptions.transport is given: RakNet over UDP, the default, or NetherNet, signaled over HTTP on the TCP side of the port.
port?
readonlyoptionalport?:number
Defined in: client/src/Client.ts:62
protocolVersion?
readonlyoptionalprotocolVersion?:number
Defined in: client/src/Client.ts:84
Which protocol to speak. Defaults to PROTOCOL_VERSION.
A server admits one version and refuses every other, so this is only worth setting to reach a server of a version this client does not default to - which is what the Bedrock capture tool does when it records a newer server's data.
Throws
Error from the constructor when the version has no layout here.
transport?
readonlyoptionaltransport?:ITransport
Defined in: client/src/Client.ts:68
Supply one for single player; omit it and the client dials over ClientOptions.network.
DecodedPacket
Defined in: client/src/net/ClientPacketRegistry.ts:25
Properties
data
readonlydata:unknown
Defined in: client/src/net/ClientPacketRegistry.ts:28
id
readonlyid:number
Defined in: client/src/net/ClientPacketRegistry.ts:26
name
readonlyname:string
Defined in: client/src/net/ClientPacketRegistry.ts:27
FleetOptions
Defined in: client/src/bot/Fleet.ts:8
Properties
behaviors?
readonlyoptionalbehaviors?: readonlystring[]
Defined in: client/src/bot/Fleet.ts:15
Behavior names, e.g. ['walk', 'chat'].
count
readonlycount:number
Defined in: client/src/bot/Fleet.ts:13
host
readonlyhost:string
Defined in: client/src/bot/Fleet.ts:9
logger?
readonlyoptionallogger?:Logger
Defined in: client/src/bot/Fleet.ts:28
loginTimeoutMs?
readonlyoptionalloginTimeoutMs?:number
Defined in: client/src/bot/Fleet.ts:29
namePrefix?
readonlyoptionalnamePrefix?:string
Defined in: client/src/bot/Fleet.ts:27
Base name; each bot gets its index appended.
network?
readonlyoptionalnetwork?:"raknet"|"nethernet"
Defined in: client/src/bot/Fleet.ts:12
Which transport every bot dials; RakNet by default.
port?
readonlyoptionalport?:number
Defined in: client/src/bot/Fleet.ts:10
ramp?
readonlyoptionalramp?:number
Defined in: client/src/bot/Fleet.ts:23
How many bots to connect per second.
Not a politeness setting: connecting hundreds at once measures how a server copes with a thundering herd, which is a different question from how it copes with hundreds of players. Ramping lets you ask the second one.
seed?
readonlyoptionalseed?:number
Defined in: client/src/bot/Fleet.ts:24
viewDistance?
readonlyoptionalviewDistance?:number
Defined in: client/src/bot/Fleet.ts:25
FleetReport
Defined in: client/src/bot/Metrics.ts:70
Properties
actions
actions:
Record<string,number>
Defined in: client/src/bot/Metrics.ts:89
connected
connected:
number
Defined in: client/src/bot/Metrics.ts:75
durationMs
durationMs:
number
Defined in: client/src/bot/Metrics.ts:72
Wall clock the run covered, in milliseconds.
failed
failed:
number
Defined in: client/src/bot/Metrics.ts:76
failures
failures:
object[]
Defined in: client/src/bot/Metrics.ts:78
One entry per distinct failure, with how many bots hit it.
count
count:
number
reason
reason:
string
loginLatencyMs
loginLatencyMs:
LatencySummary
Defined in: client/src/bot/Metrics.ts:80
From the first packet sent to standing in the world.
requested
requested:
number
Defined in: client/src/bot/Metrics.ts:74
rssBytes
rssBytes:
number
Defined in: client/src/bot/Metrics.ts:91
Resident set size of this process, which is the harness and not the server.
rttMs
rttMs:
LatencySummary
Defined in: client/src/bot/Metrics.ts:82
RakNet's smoothed estimate, sampled at the end of the run.
seed
seed:
number
Defined in: client/src/bot/Metrics.ts:73
traffic
traffic:
object
Defined in: client/src/bot/Metrics.ts:83
bytesReceived
bytesReceived:
number
bytesSent
bytesSent:
number
packetsReceived
packetsReceived:
number
packetsSent
packetsSent:
number
ITransport
Defined in: client/src/net/ITransport.ts:31
What the client needs from whatever carries its bytes.
The seam that lets single player be the same client as multiplayer: over a network this is RakNet over UDP, and in the same process it is a loopback pair, and nothing above here can tell which. It deliberately sits below batching - a transport moves opaque payloads and knows nothing about compression, encryption or packet ids, all of which belong to the session on top of it.
Properties
encrypted?
readonlyoptionalencrypted?:boolean
Defined in: client/src/net/ITransport.ts:37
Whether the transport encrypts the wire itself, as NetherNet's DTLS does. A server on such a transport still sends ServerToClientHandshake, as Bedrock Dedicated Server does over NetherNet, but both ends leave batches in the clear. Absent means it does not.
Methods
close()
close(
reason?):void
Defined in: client/src/net/ITransport.ts:47
Parameters
reason?
string
Returns
void
connect()
connect():
Promise<void>
Defined in: client/src/net/ITransport.ts:39
Returns
Promise<void>
getStats()
getStats():
TransportStats
Defined in: client/src/net/ITransport.ts:50
Counters the bot harness reports on; cheap enough to read every tick.
Returns
off()
off<
E>(event,listener):void
Defined in: client/src/net/ITransport.ts:45
Type Parameters
E
E extends keyof TransportEvents
Parameters
event
E
listener
Returns
void
on()
on<
E>(event,listener):void
Defined in: client/src/net/ITransport.ts:44
Type Parameters
E
E extends keyof TransportEvents
Parameters
event
E
listener
Returns
void
send()
send(
payload,priority?):void
Defined in: client/src/net/ITransport.ts:42
Sends one framed batch.
Parameters
payload
Buffer
priority?
Returns
void
LatencySummary
Defined in: client/src/bot/Metrics.ts:60
Properties
count
count:
number
Defined in: client/src/bot/Metrics.ts:61
max
max:
number|null
Defined in: client/src/bot/Metrics.ts:67
mean
mean:
number|null
Defined in: client/src/bot/Metrics.ts:63
min
min:
number|null
Defined in: client/src/bot/Metrics.ts:62
p50
p50:
number|null
Defined in: client/src/bot/Metrics.ts:64
p95
p95:
number|null
Defined in: client/src/bot/Metrics.ts:65
p99
p99:
number|null
Defined in: client/src/bot/Metrics.ts:66
LoginResult
Defined in: client/src/login/LoginSequence.ts:36
Properties
startGame
readonlystartGame:StartGame
Defined in: client/src/login/LoginSequence.ts:37
LoginSequenceOptions
Defined in: client/src/login/LoginSequence.ts:40
Properties
protocolVersion
readonlyprotocolVersion:number
Defined in: client/src/login/LoginSequence.ts:41
serverAddress
readonlyserverAddress:string
Defined in: client/src/login/LoginSequence.ts:43
host:port, as the client reports having dialled it.
timeoutMs?
readonlyoptionaltimeoutMs?:number
Defined in: client/src/login/LoginSequence.ts:44
PendingDimensionChange
Defined in: client/src/DimensionChange.ts:17
A dimension change the server started and this client has not yet closed the screen for.
Properties
dimension
readonlydimension:number
Defined in: client/src/DimensionChange.ts:19
The Dimension ID the server is moving us to.
loadingScreenId
readonlyloadingScreenId:number|null
Defined in: client/src/DimensionChange.ts:21
The Loading Screen Id the server expects back, or null when it sent none.
position
readonlyposition:Vector3
Defined in: client/src/DimensionChange.ts:23
Where ChangeDimension said we arrive.
RakNetTransportOptions
Defined in: client/src/net/RakNetTransport.ts:9
Properties
host
readonlyhost:string
Defined in: client/src/net/RakNetTransport.ts:10
port
readonlyport:number
Defined in: client/src/net/RakNetTransport.ts:11
timeoutMs?
readonlyoptionaltimeoutMs?:number
Defined in: client/src/net/RakNetTransport.ts:13
Overall budget for the connection attempt.
TransportEvents
Defined in: client/src/net/ITransport.ts:16
Properties
batch
batch: (
payload) =>void
Defined in: client/src/net/ITransport.ts:18
One complete Minecraft batch, still framed - id, prefix and all.
Parameters
payload
Buffer
Returns
void
close
close: (
reason) =>void
Defined in: client/src/net/ITransport.ts:19
Parameters
reason
string
Returns
void
TransportStats
Defined in: client/src/net/ITransport.ts:7
Properties
bytesReceived
readonlybytesReceived:number
Defined in: client/src/net/ITransport.ts:11
bytesSent
readonlybytesSent:number
Defined in: client/src/net/ITransport.ts:10
packetsReceived
readonlypacketsReceived:number
Defined in: client/src/net/ITransport.ts:13
packetsSent
readonlypacketsSent:number
Defined in: client/src/net/ITransport.ts:12
rtt
readonlyrtt:number|null
Defined in: client/src/net/ITransport.ts:9
Smoothed round trip in milliseconds, or null before the first measurement.
Type Aliases
PacketConstructor
PacketConstructor = new () =>
NetworkPacket<any>
Defined in: client/src/net/ClientPacketRegistry.ts:20
A packet class that can be built with no arguments, i.e. for decoding into.
Returns
NetworkPacket<any>
Variables
BEHAVIORS
constBEHAVIORS:Record<string, () =>Behavior>
Defined in: client/src/bot/behavior/Behaviors.ts:9
Behaviors by the name the command line uses.
BEHAVIOR_NAMES
constBEHAVIOR_NAMES:string[]
Defined in: client/src/bot/behavior/Behaviors.ts:16
MINECRAFT_VERSION
constMINECRAFT_VERSION:"1.26.51"='1.26.51'
Defined in: client/src/Client.ts:45
PROTOCOL_VERSION
constPROTOCOL_VERSION:2193=v2193.protocolVersion
Defined in: client/src/Client.ts:44
The protocol version this client speaks unless it is told otherwise.
One default, exactly as the server has one. A mismatch is refused by both ends with a message that says which side is behind, which is the least a client owes somebody who cannot connect.
TICK_INTERVAL_MS
constTICK_INTERVAL_MS:50=50
Defined in: client/src/bot/Bot.ts:12
The server's own rate, and therefore the rate a client's input is meaningful at.
Functions
createBehaviors()
createBehaviors(
names):Behavior[]
Defined in: client/src/bot/behavior/Behaviors.ts:25
Builds behaviors from a list of names.
Parameters
names
readonly string[]
as given on the command line, e.g. ['walk', 'chat'].
Returns
Behavior[]
Throws
when a name is not one of BEHAVIOR_NAMES, rather than silently running a fleet that does less than was asked for - a load test quietly missing half its traffic is worse than one that refuses to start.
formatReport()
formatReport(
report):string
Defined in: client/src/bot/Metrics.ts:95
Renders a report as a block of aligned text, for a terminal rather than a file.
Parameters
report
Returns
string
References
default
Renames and re-exports Client