feat: refactor world block retrieval to use getAllBlocksForAPI method
This commit is contained in:
@@ -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 });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user