Skip to main content

Client

Extends EventEmitter

The main hub for interacting with the higher level gametest API.

warning

You should never have to construct this class yourself. Timers depend on its initialization before being exported.

import { client } from 'beapi-core';

client.executeCommand('say Hello :)');

Constructor

new Client();

Properties

players READONLY

Manager for all currently connected players.

Type: PlayerManager


entities READONLY

Manager for all active entities in the world.

Type: EntityManager


commands READONLY

Manager for controlling BeAPI commands.

Type: CommandManager


world READONLY

Manager for doing tasks as the world.

Type: WorldManager


currentVersion READONLY

BeAPI-core current version.

Type: string


currentMCBE READONLY

note

We may forget to update, please submit an issue if outdated.

Minecraft Bedrock Edition current version.

Type: string


currentProtocol READONLY

note

We may forget to update, please submit an issue if outdated.

Minecraft Bedrock Edition current protocol version.

Type: number


Methods

loadEvent

Add an event to BeAPI client.

loadEvent(event);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
eventAbstractEventundefinedExtended AbstractEvent constructor.

Returns

void


removeEvent

Add an event to BeAPI client.

loadEvent(name);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
namestringundefinedThe name of the event.

Returns

void


getEvent

Add an event to BeAPI client.

loadEvent(name);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
namestringundefinedThe name of the event.

Returns

AbstractEvent | undefined


verifyIEvent

Ensures given event exists in gametests events.

verifyIEvent(name);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
namestringundefinedThe name of the event.
note

The name "custom" will return true because this is telling us the event is not provided by Minecraft.

Returns

boolean


getAllIEvents

Returns the names of all gametest events.

getAllIEvents();

Returns

string[]


executeCommand

Execute a command as system admin.

executeCommand(cmd, dimension, debug);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
cmdstringundefinedMinecraft command to execute.
dimensionDimension?✔️overworldDimension to execute given command in.
debugboolean?✔️falsePipe logs to debug console.

Returns

ServerCommandResponse


Events

OnChat

Emitted on player chat message.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataOnChatEvent--Chat data.

OnJoin

Emitted on player join.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

OnLeave

Emitted on player leave.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer | string--Player instance or player name.

Tick

Emitted on every tick (1 /50ms).

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
tickTickEvent--Tick data.

ItemUse

Emitted on item usage.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataItemUseEvent--Item use data.

ItemInteract

Emitted on item interact.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataItemInteractEvent--Item interact data.

EntityDestroyed

Emitted when an entity is destroyed.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
entityEntity--Entity that was destroyed.

EntityCreated

Emitted when an entity is created.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
entityEntity--Entity that was created.

BlockDestroyed

Emitted when a client breaks a block.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataClientBlockBreakEvent--Block break event data.

BlockCreated

Emitted when a client places a block.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataClientBlockEvent--Block place event data.

PlayerInViewVector

Emitted when a player is in view vector of another player.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataPlayerInViewVectorEvent--View vector event data.

PlayerAttacked

Emitted when a player is attacked.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataPlayerInViewVectorEvent--View vector event data.

EntityInViewVector

Emitted when an entity is in view vector of a player.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataEntityInViewVectorEvent--View vector event data.

EntityAttacked

Emitted when an entity is attacked.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataEntityInViewVectorEvent--View vector event data.

PlayerTag

Emitted when a player recieves a tag prefixed with beapi:.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataPlayerTagEvent--Player tag event data.

EntityTag

Emitted when an entity recieves a tag prefixed with beapi:.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataEntityTagEvent--Entity tag event data.

Explosion

Emitted when on explosion.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
dataExplosionEvent--Explosion event data.

EnteredWater

Emitted when a player enters water.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

ExitedWater

Emitted when a player exits water.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StartedBurning

Emitted when a player starts burning.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StoppedBurning

Emitted when a player stops burning.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

Jump

Emitted when a player jumps.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

Landed

Emitted when a player lands.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StartedMoving

Emitted when a player starts moving.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StoppedMoving

Emitted when a player stops moving.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StartedRiding

Emitted when a player starts riding.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StoppedRiding

Emitted when a player stops riding.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StartedSleeping

Emitted when a player starts sleeping.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StoppedSleeping

Emitted when a player stops sleeping.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StartedSneaking

Emitted when a player starts sneaking.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StoppedSneaking

Emitted when a player stops sneaking.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StartedSprinting

Emitted when a player starts sprinting.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StoppedSprinting

Emitted when a player stops sprinting.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StartedSwimming

Emitted when a player starts swimming.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

StoppedSwimming

Emitted when a player stops swimming.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

Swing

Emitted when a player swings arm.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

Death

Emitted when a player dies.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.

Respawn

Emitted when a player respawns.

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
playerPlayer--Player instance.