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);
|
webClients.add(ws);
|
||||||
|
|
||||||
// Send current turtle data and world blocks to new client
|
// Send current turtle data and world blocks to new client
|
||||||
const blocks = [];
|
const blocks = worldBlocks.getAllBlocksForAPI();
|
||||||
for (const [key, blockData] of worldBlocks.entries()) {
|
|
||||||
const [x, y, z] = key.split(',').map(Number);
|
|
||||||
blocks.push({ x, y, z, ...blockData });
|
|
||||||
}
|
|
||||||
|
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
type: 'initial_state',
|
type: 'initial_state',
|
||||||
@@ -635,14 +631,7 @@ app.get('/api/turtle/:id/home', (req, res) => {
|
|||||||
|
|
||||||
// Get world blocks for map visualization
|
// Get world blocks for map visualization
|
||||||
app.get('/api/world/blocks', (req, res) => {
|
app.get('/api/world/blocks', (req, res) => {
|
||||||
const blocks = [];
|
const blocks = worldBlocks.getAllBlocksForAPI();
|
||||||
for (const [key, blockData] of worldBlocks.entries()) {
|
|
||||||
const [x, y, z] = key.split(',').map(Number);
|
|
||||||
blocks.push({
|
|
||||||
x, y, z,
|
|
||||||
...blockData
|
|
||||||
});
|
|
||||||
}
|
|
||||||
res.json({ blocks });
|
res.json({ blocks });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user