Implement proximity chat. Very raw at the moment

This commit is contained in:
haxi0
2026-03-09 16:04:58 +03:00
parent a195ac7172
commit 7b748a433d
26 changed files with 672 additions and 5 deletions
+15
View File
@@ -34,6 +34,7 @@
// 4J Added
#include "..\Minecraft.World\net.minecraft.world.item.crafting.h"
#include "Options.h"
#include "..\Minecraft.World\VoiceChatPacket.h"
Random PlayerConnection::random;
@@ -1801,3 +1802,17 @@ bool PlayerConnection::isGuest()
return isGuest;
}
}
void PlayerConnection::handleVoiceChat(VoiceChatPacket *packet)
{
if (done) return;
if (packet == nullptr || packet->dataLength <= 0) return;
// Stamp the sender's entity ID so clients know who is speaking
packet->senderPlayerId = player->entityId;
// Broadcast to all connected players (including the sender's client, which will filter itself)
auto sharedPacket = std::make_shared<VoiceChatPacket>(
packet->senderPlayerId, packet->audioData, packet->dataLength);
server->getPlayers()->broadcastAll(sharedPacket);
}