From dfd1cb00283bc0028cb458be80f2dffbd5f6db97 Mon Sep 17 00:00:00 2001 From: gguio Date: Tue, 18 Jun 2024 13:33:23 +0400 Subject: [PATCH] build doesnt work right --- src/react/Minimap.tsx | 4 ++++ src/react/MinimapDrawer.ts | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/react/Minimap.tsx b/src/react/Minimap.tsx index 7f46c349..291fdc4a 100644 --- a/src/react/Minimap.tsx +++ b/src/react/Minimap.tsx @@ -7,7 +7,9 @@ export default () => { const drawerRef = useRef(null) function updateMap () { + console.log('test') if (drawerRef.current && canvasTick.current % 10 === 0) { + console.log(drawerRef.current.worldColors) drawerRef.current.draw(bot) if (canvasTick.current % 300 === 0) { drawerRef.current.clearCache(bot.entity.position.x, bot.entity.position.z) @@ -23,9 +25,11 @@ export default () => { }, [canvasRef.current]) useEffect(() => { + console.log('set update') bot.on('move', updateMap) return () => { + console.log('delete update') bot.off('move', updateMap) } }, []) diff --git a/src/react/MinimapDrawer.ts b/src/react/MinimapDrawer.ts index a5f12a60..e96d177d 100644 --- a/src/react/MinimapDrawer.ts +++ b/src/react/MinimapDrawer.ts @@ -48,6 +48,7 @@ export class MinimapDrawer { if (bot) { this.updateWorldColors(bot) + console.log(this.worldColors) } else { this.ctx.strokeStyle = 'black' this.ctx.beginPath() @@ -93,7 +94,8 @@ export class MinimapDrawer { getHighestBlockColor (bot: BotType, x: number, z: number) { const key = `${x},${z}` - if (Object.keys(this.worldColors).includes(key)) { + if (this.worldColors[key]) { + console.log('using cashed value') return this.worldColors[key] } let block = null as import('prismarine-block').Block | null @@ -113,7 +115,7 @@ export class MinimapDrawer { } clearCache (currX: number, currZ: number) { - for (const key of Object.keys(this.worldColors)) { + for (const key in this.worldColors) { const [x, z] = key.split(',').map(Number) if (this.getDistance(x, z, currX, currZ) > this.radius * 5) { delete this.worldColors[`${x},${z}`]