feat: Implement block discovery endpoint and update worldBlocks state on discovery

This commit is contained in:
MayaTheShy
2026-02-20 01:23:05 -05:00
parent 855874576d
commit 0eac9497de
2 changed files with 36 additions and 18 deletions

View File

@@ -77,6 +77,15 @@ export const useTurtleStore = create((set, get) => ({
}
}
}));
} else if (data.type === 'block_discovered') {
if (data.block) {
set(state => {
const blockMap = new Map(state.worldBlocks.map(b => [`${b.x},${b.y},${b.z}`, b]));
const key = `${data.block.x},${data.block.y},${data.block.z}`;
blockMap.set(key, data.block);
return { worldBlocks: Array.from(blockMap.values()) };
});
}
}
} catch (error) {
console.error('Error processing message:', error);