Skip to content

Commit 76649cd

Browse files
committed
feat: в 3d viewer добавлен хот бар
1 parent 8d0a0f4 commit 76649cd

586 files changed

Lines changed: 253 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/src/core/BotProcess.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,13 @@ process.on('message', async (message) => {
318318
}
319319
break;
320320

321+
case 'hotbar_slot':
322+
if (command.slot !== undefined && command.slot >= 0 && command.slot <= 8) {
323+
bot.setQuickBarSlot(command.slot);
324+
sendLog(`[Viewer] Hotbar slot changed to ${command.slot}`);
325+
}
326+
break;
327+
321328
case 'place':
322329
if (command.position && command.blockType) {
323330
const referenceBlock = bot.blockAt(new Vec3(command.position.x, command.position.y, command.position.z));
@@ -1109,6 +1116,29 @@ process.on('message', async (message) => {
11091116
});
11101117
}
11111118
});
1119+
1120+
bot.on('blockUpdate', (oldBlock, newBlock) => {
1121+
if (process.send && oldBlock && newBlock) {
1122+
process.send({
1123+
type: 'viewer:blockUpdate',
1124+
payload: {
1125+
position: {
1126+
x: newBlock.position.x,
1127+
y: newBlock.position.y,
1128+
z: newBlock.position.z
1129+
},
1130+
oldBlock: {
1131+
type: oldBlock.type,
1132+
name: oldBlock.name
1133+
},
1134+
newBlock: {
1135+
type: newBlock.type,
1136+
name: newBlock.name
1137+
}
1138+
}
1139+
});
1140+
}
1141+
});
11121142
} catch (err) {
11131143
sendLog(`[CRITICAL] Критическая ошибка при создании бота: ${err.stack}`);
11141144
process.exit(1);

backend/src/core/services/MinecraftViewerService.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class MinecraftViewerService {
110110
this.viewerNamespace.to(`bot:${botId}`).emit('viewer:health', message.payload);
111111
} else if (message.type === 'viewer:chat') {
112112
this.viewerNamespace.to(`bot:${botId}`).emit('viewer:chat', message.payload);
113+
} else if (message.type === 'viewer:blockUpdate') {
114+
this.viewerNamespace.to(`bot:${botId}`).emit('viewer:blockUpdate', message.payload);
113115
}
114116
});
115117
}
316 Bytes
357 Bytes
135 Bytes
227 Bytes
206 Bytes
184 Bytes
219 Bytes
207 Bytes

0 commit comments

Comments
 (0)