diff --git a/index.d.ts b/index.d.ts index ed6c697ad..1bcfb9e7c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -162,6 +162,7 @@ export interface BotEvents { bossBarDeleted: (bossBar: BossBar) => Promise | void bossBarUpdated: (bossBar: BossBar) => Promise | void resourcePack: (url: string, hash?: string, uuid?: string) => Promise | void + heldItemChanged: (newItem: Item | null) => Promise | void particle: (particle: Particle) => Promise | void } @@ -386,8 +387,8 @@ export interface Bot extends TypedEmitter { times?: number ) => Promise - - + + setCommandBlock: (pos: Vec3, command: string, options: CommandBlockOptions) => void clickWindow: ( diff --git a/lib/plugins/inventory.js b/lib/plugins/inventory.js index 70db3128f..2f8ad2155 100644 --- a/lib/plugins/inventory.js +++ b/lib/plugins/inventory.js @@ -547,7 +547,7 @@ function inject (bot, { hideErrors }) { } const window = bot.currentWindow || bot.inventory - assert.ok(mode >= 0 && mode <= 4) + assert.ok(mode >= 0 && mode <= 6) const actionId = createActionNumber() const click = { @@ -728,6 +728,11 @@ function inject (bot, { hideErrors }) { const newItem = Item.fromNotch(packet.item) bot._setSlot(packet.slot, newItem, window) }) + bot.inventory.on('updateSlot', (index) => { + if (index === bot.quickBarSlot + bot.inventory.hotbarStart) { + bot.emit('heldItemChanged') + } + }) bot._client.on('window_items', (packet) => { const window = packet.windowId === 0 ? bot.inventory : bot.currentWindow if (!window || window.id !== packet.windowId) {