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

49 lines
823 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];
2023-02-12 18:53:55 -06:00
pub const PROTOCOL_ID: u16 = 1;
#[derive(Encode, Decode, Clone)]
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
}
2023-02-13 21:27:27 -06:00
#[derive(Encode, Decode, Clone)]
pub struct InitData {
}
2023-02-12 18:53:55 -06:00
#[derive(Encode, Decode, Clone)]
2023-01-29 20:42:58 -06:00
pub enum ServerToClientMessage {
2023-02-13 21:27:27 -06:00
ServerHello {
init: InitData
},
ServerFuckOff {
reason: String,
},
PlayerPositionChanged {
client_id: u8,
position: Vec3Arr,
direction: QuatArr,
},
ChunkResponse {
chunk: IVec3Arr,
data: BlockData
}
2023-01-29 20:42:58 -06:00
}