feat: Implement block discovery endpoint and update worldBlocks state on discovery
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user