Skip to content

API reference / @jsprismarine/client / Client

Class: Client ​

Defined in: client/src/Client.ts:102

A Minecraft: Bedrock Edition client, with no interface attached to it.

Everything the game needs and nothing it needs a screen for, which is what lets the same object serve the windowed client, the headless one and each of the several hundred connections a load test opens. It owns a transport, a session and a login; what it deliberately does not own is a renderer, an input device or a main loop.

Example ​

typescript
const client = new Client({ host: '127.0.0.1', displayName: 'Steve' });
await client.connect();
client.on('text', (message) => console.log(message));

Extends ​

  • EventEmitter

Constructors ​

Constructor ​

new Client(options): Client

Defined in: client/src/Client.ts:118

Parameters ​

options ​

ClientOptions

Returns ​

Client

Overrides ​

EventEmitter.constructor

Methods ​

connect() ​

connect(): Promise<StartGame>

Defined in: client/src/Client.ts:204

Connects, logs in, and resolves once the server has spawned us.

One call rather than connect then login, because there is nothing useful a caller can do between the two: every packet before the spawn belongs to the handshake.

Returns ​

Promise<StartGame>


disconnect() ​

disconnect(reason?): void

Defined in: client/src/Client.ts:230

Parameters ​

reason? ​

string = 'client disconnect'

Returns ​

void


getCredits() ​

getCredits(): Credits

Defined in: client/src/Client.ts:260

The end credits responder, which answers the server's ShowCredits Start.

Returns ​

Credits


getDimensionChange() ​

getDimensionChange(): DimensionChange

Defined in: client/src/Client.ts:255

The dimension change responder, which also knows whether one is in progress.

Returns ​

DimensionChange


getIdentity() ​

getIdentity(): Promise<Identity>

Defined in: client/src/Client.ts:268

Returns ​

Promise<Identity>


getRegistry() ​

getRegistry(): ClientPacketRegistry

Defined in: client/src/Client.ts:250

Returns ​

ClientPacketRegistry


getSession() ​

getSession(): ClientSession

Defined in: client/src/Client.ts:246

Returns ​

ClientSession


getStartGame() ​

getStartGame(): StartGame | null

Defined in: client/src/Client.ts:242

Null until the login completes.

Returns ​

StartGame | null


getStats() ​

getStats(): TransportStats

Defined in: client/src/Client.ts:264

Returns ​

TransportStats


isConnected() ​

isConnected(): boolean

Defined in: client/src/Client.ts:237

Returns ​

boolean