Skip to main content

Events

Use mc.on(eventName, handler) to subscribe. It resolves with an unsubscribe function.

const off = await mc.on('chat', ({ message }) => {
console.log(message);
});

// Later
await off();

Subscribe only to events your plugin needs. Event monitoring is inactive when there are no subscribers.

Event names​

EventDescription
movePosition and rotation changed
chatA chat, game, or action bar message arrived
windowOpenA handled container opened
windowCloseA handled container closed
updateSlotVisible container slots or the cursor item changed
forceMoveThe player moved an unusually large distance at once
healthChangedHealth, maximum health, or food changed
deathThe player died
respawnThe player respawned
kickedThe player disconnected
pathArrivedNavigation reached its target
pathFailedNavigation stopped before reaching its target
entitySpawnedEntities entered the nearby tracked area
entityDiedNearby entities died
entityDespawnedEntities disappeared without a detected death
playerStateChangedFire, item-use, swimming, gliding, or air state changed
heldItemChangedThe main hand, off hand, or selected hotbar item changed
effectsChangedActive status effects changed
dimensionChangedThe player changed dimension
blockChangedBlocks changed inside a watched region
uiActionThe user interacted with a plugin control screen
taskCompletedAn entity automation task completed
taskFailedAn entity automation task failed

Payloads​

move​

Movement events are throttled and sent only after a position or rotation change.

{
x: number;
y: number;
z: number;
yaw: number;
pitch: number;
dimension?: string;
ts: number;
}

chat​

{
message: string;
kind: 'chat' | 'game' | 'actionbar';
ts: number;
}

windowOpen​

{
syncId: number;
screenClass?: string;
title?: string;
ts: number;
}

windowClose​

{
syncId: number;
ts: number;
}

updateSlot​

Only changed slots are included.

{
syncId: number;
changedSlots: {
slot: number;
stack: ItemStack;
}[];
cursorStack: ItemStack | null;
ts: number;
}

forceMove​

{
from: { x: number; y: number; z: number };
to: { x: number; y: number; z: number };
dist: number;
ts: number;
}

healthChanged​

Health events are sent only after a change and are limited to one event every 250 ms.

{
health: number;
maxHealth: number;
food: number;
ts: number;
}

death and respawn​

{
ts: number;
}

kicked​

{
reason: string;
ts: number;
}

pathArrived​

{
durationMs: number;
nodes: number;
taskId?: string;
ts: number;
}

pathFailed​

Common reasons include no_path, out_of_range, goal_unreachable, stuck, cancelled, input_override, and disconnected.

{
reason: string;
taskId?: string;
ts: number;
}

entitySpawned​

Nearby entity checks run at most once per second.

{
entities: {
id: number;
type: string;
name: string;
x: number;
y: number;
z: number;
isAlive: boolean;
hostile: boolean;
distance?: number;
}[];
ts: number;
}

entityDied​

{
ids: number[];
ts: number;
}

entityDespawned​

This includes entities that left the nearby tracked area, unloaded, or otherwise disappeared without a detected death.

{
ids: number[];
ts: number;
}

playerStateChanged​

{
onFire: boolean;
usingItem: boolean;
swimming: boolean;
gliding: boolean;
air: number;
ts: number;
}

heldItemChanged​

{
mainHand: ItemStack;
offHand: ItemStack;
selectedHotbarSlot?: number;
ts: number;
}

effectsChanged​

{
effects: {
id: string;
amplifier: number;
duration: number;
}[];
ts: number;
}

dimensionChanged​

{
from: string;
to: string;
ts: number;
}

blockChanged​

Each event contains at most 128 changed blocks.

{
watchId: string;
changes: BlockInfo[];
ts: number;
}

uiAction​

The action is change for toggles, click for buttons, and close when the screen closes.

{
uiId: string;
elementId: string;
action: 'click' | 'change' | 'close';
value: boolean;
ts: number;
}

taskCompleted​

{
taskId: string;
type: string;
mined?: number;
skipped?: number;
ts: number;
}

taskFailed​

{
taskId: string;
type: string;
reason?: string;
mined?: number;
skipped?: number;
ts: number;
}