kubi/kubi-shared/src/networking/messages.rs

40 lines
690 B
Rust
Raw Normal View History

use bincode::{Encode, Decode};
use crate::chunk::BlockData;
2023-01-29 20:42:58 -06:00
type IVec3Arr = [i32; 3];
type Vec3Arr = [f32; 3];
type QuatArr = [f32; 3];
#[derive(Encode, Decode)]
2023-01-29 20:42:58 -06:00
pub enum ClientToServerMessage {
ClientHello {
username: String,
password: Option<String>,
},
PositionChanged {
position: Vec3Arr,
2023-02-07 19:29:29 -06:00
velocity: Vec3Arr,
direction: QuatArr,
},
ChunkRequest {
chunk: IVec3Arr,
},
2023-01-29 20:42:58 -06:00
}
#[derive(Encode, Decode)]
2023-01-29 20:42:58 -06:00
pub enum ServerToClientMessage {
2023-02-07 19:29:29 -06:00
ServerHello,
ServerFuckOff {
reason: String,
},
PlayerPositionChanged {
client_id: u8,
position: Vec3Arr,
direction: QuatArr,
},
ChunkResponse {
chunk: IVec3Arr,
data: BlockData
}
2023-01-29 20:42:58 -06:00
}