initial commit

This commit is contained in:
Snowiiii committed 2024-07-28 23:07:26 +02:00
commit 419513d2e7
19 files changed
+2205

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
use bytebuf::buffer::ByteBuffer;
use serde::{Deserialize, Serialize};
pub mod bytebuf;
pub mod client;
pub mod server;
type VarInt = i32;
type VarLong = i64;
#[derive(Debug)]
pub enum ConnectionState {
HandShake,
Status,
Login,
Transfer,
}
impl ConnectionState {
pub fn from_varint(var_int: VarInt) -> Self {
match var_int {
1 => Self::Status,
2 => Self::Login,
3 => Self::Transfer,
_ => panic!("Unexpected Status {}", var_int),
}
}
}
#[derive(Debug)]
pub struct RawPacket {
pub len: VarInt,
pub id: VarInt,
pub bytebuf: ByteBuffer,
}
pub trait ClientPacket {
const PACKET_ID: VarInt;
fn write(&self, bytebuf: &mut ByteBuffer);
}
#[derive(Serialize, Deserialize)]
pub struct StatusResponse {
pub version: Version,
pub description: String,
// Players, favicon ...
}
#[derive(Serialize, Deserialize)]
pub struct Version {
pub version: String,
pub protocol: u32,
}