From 4d5d2162e650c1e2bd8acdaa09891ac4dd36f1c7 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sun, 22 Mar 2026 11:45:24 -0400 Subject: [PATCH] feat: refactor world block retrieval to use getAllBlocksForAPI method --- server/server.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) 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 }); });