public void HandleMessage(byte[] receivedData) { Vector3Int pos; switch (receivedData[0]) { case VmNetworking.SendBlockChange: pos = Vector3Int.FromBytes(receivedData, 1); ushort data = BlockData.RestoreBlockData(receivedData, 13); server.ReceiveChange(ref pos, data, ID); break; case VmNetworking.RequestChunkData: pos = Vector3Int.FromBytes(receivedData, 1); if (debugClientConnection) { Debug.Log("ClientConnection.HandleMessage (" + Thread.CurrentThread.ManagedThreadId + "): " + ID + " " + pos); } server.RequestChunk(ref pos, ID); break; } }
public void HandleMessage(byte[] receivedData) { switch (receivedData[0]) { case VmNetworking.SendBlockChange: Vector3Int pos = Vector3Int.FromBytes(receivedData, 1); ushort data = BitConverter.ToUInt16(receivedData, 13); ReceiveChange(ref pos, new BlockData(data)); break; case VmNetworking.transmitChunkData: ReceiveChunk(receivedData); break; } }
private void ReceiveChunk(byte[] data) { Vector3Int pos = Vector3Int.FromBytes(data, 1); Chunk chunk = world.chunks.Get(ref pos); // for now just issue an error if it isn't yet loaded if (chunk == null) { Debug.LogError("VmClient.ReceiveChunk (" + Thread.CurrentThread.ManagedThreadId + "): " + "Could not find chunk for " + pos); } else { chunk.blocks.ReceiveChunkData(data); } }