+void Server::SetPlayerModel(const CompositeModel &m) noexcept {
+ player_model = &m;
+ for (ClientConnection &client : clients) {
+ client.SetPlayerModel(m);
+ }
+}
+
+bool Server::HasPlayerModel() const noexcept {
+ return player_model;
+}
+
+const CompositeModel &Server::GetPlayerModel() const noexcept {
+ return *player_model;
+}
+
+void Server::SetBlock(Chunk &chunk, int index, const Block &block) {
+ chunk.SetBlock(index, block);
+ // TODO: batch chunk changes
+ auto pack = Packet::Make<Packet::BlockUpdate>(GetPacket());
+ pack.WriteChunkCoords(chunk.Position());
+ pack.WriteBlockCount(uint32_t(1));
+ pack.WriteIndex(index, 0);
+ pack.WriteBlock(chunk.BlockAt(index), 0);
+ GetPacket().len = sizeof(Packet::Header) + Packet::BlockUpdate::GetSize(1);
+ for (ClientConnection &client : clients) {
+ if (client.ChunkInRange(chunk.Position())) {
+ client.Send();
+ }
+ }
+}
+