build doesnt work right
This commit is contained in:
parent
55ce44585f
commit
dfd1cb0028
2 changed files with 8 additions and 2 deletions
|
|
@ -7,7 +7,9 @@ export default () => {
|
|||
const drawerRef = useRef<MinimapDrawer | null>(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)
|
||||
}
|
||||
}, [])
|
||||
|
|
|
|||
|
|
@ -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}`]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue