2023-01-30 20:06:30 -06:00
|
|
|
use bincode::{Encode, Decode};
|
|
|
|
use crate::chunk::BlockData;
|
2023-01-29 20:42:58 -06:00
|
|
|
|
2023-01-30 20:06:30 -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 {
|
2023-01-30 18:28:35 -06:00
|
|
|
ClientHello {
|
|
|
|
username: String,
|
|
|
|
password: Option<String>,
|
|
|
|
},
|
|
|
|
PositionChanged {
|
2023-01-30 20:06:30 -06:00
|
|
|
position: Vec3Arr,
|
2023-02-07 19:29:29 -06:00
|
|
|
velocity: Vec3Arr,
|
2023-01-30 20:06:30 -06:00
|
|
|
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
|
|
|
|
},
|
2023-01-30 18:28:35 -06:00
|
|
|
ServerFuckOff {
|
|
|
|
reason: String,
|
|
|
|
},
|
|
|
|
PlayerPositionChanged {
|
2023-01-30 20:06:30 -06:00
|
|
|
client_id: u8,
|
|
|
|
position: Vec3Arr,
|
|
|
|
direction: QuatArr,
|
2023-01-30 18:28:35 -06:00
|
|
|
},
|
2023-01-30 20:06:30 -06:00
|
|
|
ChunkResponse {
|
|
|
|
chunk: IVec3Arr,
|
|
|
|
data: BlockData
|
|
|
|
}
|
2023-01-29 20:42:58 -06:00
|
|
|
}
|