MineJSv0.7.0

ClientEvents

interface ClientEvents { actionBar: [message: string]; actionBarRaw: [textComponent: TextComponent]; blockUpdate: [x: number, y: number, z: number, newBlockId: number]; closeContainer: []; connect: []; containerContent: [container: Container, carryingItem: Slot]; containerProperty: [container: Container]; death: [message: string]; deathRaw: [rawMessage: TextComponent]; destroy: []; disconnect: [reason: string]; disconnectRaw: [textComponent: TextComponent]; failedMessage: [message: Message]; health: [health: Health]; loadChunk: [chunkX: number, sectionY: number, chunkZ: number]; message: [message: Message]; openContainer: [container: Container]; orphanBlockUpdate: [x: number, y: number, z: number, blockId: number]; playerPosition: [position: BaseVec3]; pong: [latency: number]; ready: []; registryData: [data: RegistryData]; removeEntity: [entityId: number]; spawnEntity: [entity: Entity]; systemMessage: [message: string]; systemMessageRaw: [textComponent: TextComponent]; tablist: [newTablist: { footer: { raw: TextComponent; text: string }; header: { raw: TextComponent; text: string } }]; unloadChunk: [chunkX: number, chunkZ: number]; updateEntity: [entityId: number]; }

Source: client.ts:82


Properties

actionBar: [message: string]

The action bar

This event only provide the parsed string. To get the unparsed, or the raw one with decoration, use actionBarRaw

actionBarRaw: [textComponent: TextComponent]

The raw action bar

blockUpdate: [x: number, y: number, z: number, newBlockId: number]

When a block is updated

When you place a block in the world, instead of resending a whole chunk, which is very costly, the server will send only newly placed block and its information.

closeContainer: []

When the opening container is closed

connect: []

When the TCP socket connect is initted sucessfully

containerContent: [container: Container, carryingItem: Slot]

When the packet contain the content of the container is received

containerProperty: [container: Container]

When the packet contain the property of the container is received

death: [message: string]

The death message shown on the death screen.

This event only provide the parsed string. To get the unparsed, or the raw one with decoration, use deathRaw

deathRaw: [rawMessage: TextComponent]

The death raw message.

destroy: []

When the TCP socket connection is destroyed

disconnect: [reason: string]

When the client got disconnected from server.

This event only provide the parsed string. To get the unparsed, or the raw one with decoration, use disconnectRaw. But, the disconnectRaw is only fired when the disconnection come from the server, or the server disconnect the client. Sometime, the disconnect will be fired within the client, meaning that there will be no disconnectRaw

disconnectRaw: [textComponent: TextComponent]

When the disconnection come with the raw Text Component.

failedMessage: [message: Message]

When a message is failed to be verified against the signature sent with it

health: [health: Health]

When server update player health

loadChunk: [chunkX: number, sectionY: number, chunkZ: number]

When the chunk is loaded

Explaining the chunkX, sectionY, chunkZ: A chunk in Minecraft is a region which length and width is 16 and the height extends to the limit. But when sending the packet, the chunk is divided into smaller section which volume is 16x16x16. So the chunkX and chunkZ is the chunk position and sectionY is the section within that chunk, counting from the bedrock up to the sky

message: [message: Message]

When a chat message got broadcasted

openContainer: [container: Container]

When a container is opened

This event will be fired when client click on a block (with openBlock method) that is a container or when server believe that you just open a container (with open_screen packet).

orphanBlockUpdate: [x: number, y: number, z: number, blockId: number]

Like blockUpdate but its chunk is not in the memory.

playerPosition: [position: BaseVec3]

When server send Player Position Synchronization packet.

Note: this event is not fired when the client is moved by holding the input.

To get the player current position, use getPosition method

pong: [latency: number]

The response of the ping request.

The latency is in ms.

ready: []

When the client is ready.

Specifically, when the packet Login (play) is received.

Most of the client method require this event to be fired in order to work.

registryData: [data: RegistryData]

The registry_data packet

removeEntity: [entityId: number]

When an entity go out of client view distance or despawned

spawnEntity: [entity: Entity]

When an entity is spawned or appeared in the client view distance

systemMessage: [message: string]

The system message

This event only provide the parsed string. To get the unparsed, or the raw one with decoration, use systemMessageRaw

systemMessageRaw: [textComponent: TextComponent]

The system message with the Text Component for decorations

tablist: [newTablist: { footer: { raw: TextComponent; text: string }; header: { raw: TextComponent; text: string } }]

When tab list is updated

{"text":""} mean remove header or footer.

unloadChunk: [chunkX: number, chunkZ: number]

When the chunk got deleted by the server

See the chunkX and chunkZ explaination in loadChunk events

updateEntity: [entityId: number]

When an entity is updated, including position, rotation, etc...