public void HandleMessage(byte[] receivedData) { Vector3Int pos; switch (receivedData[0]) { case VmNetworking.SendBlockChange: pos = Vector3Int.FromBytes(receivedData, 1); ushort type = BitConverter.ToUInt16(receivedData, 13); server.ReceiveChange(pos, type, ID); break; case VmNetworking.RequestChunkData: pos = Vector3Int.FromBytes(receivedData, 1); if (debugClientConnection) { Debug.Log("ClientConnection.HandleMessage (" + Thread.CurrentThread.ManagedThreadId + "): " + ID + " " + pos); } server.RequestChunk(pos, ID); break; } }
public void HandleMessage(byte[] receivedData) { switch (receivedData[0]) { case VmNetworking.SendBlockChange: Vector3Int pos = Vector3Int.FromBytes(receivedData, 1); ushort type = BitConverter.ToUInt16(receivedData, 13); ReceiveChange(pos, new BlockData(type)); break; case VmNetworking.transmitChunkData: ReceiveChunk(receivedData); break; } }
private void ReceiveChunk(byte[] data) { Vector3Int pos = Vector3Int.FromBytes(data, 1); Chunk chunk = world.chunks.Get(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); } }