diff --git a/server/server.js b/server/server.js index d5aa79e..4d08f2c 100644 --- a/server/server.js +++ b/server/server.js @@ -388,11 +388,7 @@ wss.on('connection', (ws, req) => { webClients.add(ws); // Send current turtle data and world blocks to new client - const blocks = []; - for (const [key, blockData] of worldBlocks.entries()) { - const [x, y, z] = key.split(',').map(Number); - blocks.push({ x, y, z, ...blockData }); - } + const blocks = worldBlocks.getAllBlocksForAPI(); ws.send(JSON.stringify({ type: 'initial_state', @@ -635,14 +631,7 @@ app.get('/api/turtle/:id/home', (req, res) => { // Get world blocks for map visualization app.get('/api/world/blocks', (req, res) => { - const blocks = []; - for (const [key, blockData] of worldBlocks.entries()) { - const [x, y, z] = key.split(',').map(Number); - blocks.push({ - x, y, z, - ...blockData - }); - } + const blocks = worldBlocks.getAllBlocksForAPI(); res.json({ blocks }); });