feat: refactor world block retrieval to use getAllBlocksForAPI method

This commit is contained in:
MayaTheShy
2026-03-22 11:45:24 -04:00
parent 24570d0fc0
commit 4d5d2162e6

View File

@@ -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 });
});