diff --git a/src/index.ts b/src/index.ts index 69886b3b0..8dbc46cf3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -547,6 +547,15 @@ async function connect (connectOptions: ConnectOptions) { window.Vec3 = Vec3 window.pathfinder = pathfinder + // patch mineflayer + // todo move to mineflayer + bot.inventory.on('updateSlot', (index) => { + if ((index as unknown as number) === bot.quickBarSlot + bot.inventory.hotbarStart) { + //@ts-expect-error + bot.emit('heldItemChanged') + } + }) + miscUiState.gameLoaded = true miscUiState.loadedServerIndex = connectOptions.serverIndex ?? '' customEvents.emit('gameLoaded') diff --git a/src/react/HeldMapUi.tsx b/src/react/HeldMapUi.tsx index 242cba030..9187c98b8 100644 --- a/src/react/HeldMapUi.tsx +++ b/src/react/HeldMapUi.tsx @@ -20,13 +20,14 @@ export default () => { return canvas.toDataURL('image/png') }) + // TODO delete maps! const updateHeldMap = () => { setDataUrl(null) if (!bot.heldItem || !['filled_map', 'map'].includes(bot.heldItem.name)) return // setDataUrl(true) const mapNumber = (bot.heldItem?.nbt?.value as any)?.map?.value // if (!mapNumber) return - setDataUrl(bot.mapDownloader.maps[mapNumber] as unknown as string) + setDataUrl(bot.mapDownloader.maps?.[mapNumber] as unknown as string) } bot.on('heldItemChanged' as any, () => {