62 lines
1.5 KiB
Rust
62 lines
1.5 KiB
Rust
use std::sync::Arc;
|
|
|
|
use tokio::sync::Mutex;
|
|
use uuid::Uuid;
|
|
|
|
mod protocol;
|
|
mod server;
|
|
mod plugin;
|
|
mod ser;
|
|
mod varint;
|
|
mod client;
|
|
|
|
pub static QC_VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
|
|
pub type ArcMutex<T> = Arc<Mutex<T>>;
|
|
pub type JsonValue = serde_json::Value;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct Player {
|
|
name: String,
|
|
uuid: Uuid,
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct ClientInfo {
|
|
addr: String,
|
|
port: u16,
|
|
proto_version: i32,
|
|
proto_name: &'static str,
|
|
}
|
|
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
server::run_server().await.unwrap()
|
|
}
|
|
|
|
// Temporary code used to parse packets collected from vanilla Minecraft servers,
|
|
// mostly to collect dimension/registry codecs
|
|
#[cfg(no)]
|
|
fn main() {
|
|
use varint::VarInt;
|
|
use ser::Deserializable;
|
|
use std::io::{Cursor, Write};
|
|
let packet = include_bytes!("/home/trimill/code/minecraft/joingame/1.16.5_bin");
|
|
let mut r = Cursor::new(packet);
|
|
let _packet_id = VarInt::deserialize(&mut r).unwrap();
|
|
let _eid = i32::deserialize(&mut r).unwrap();
|
|
let _hc = bool::deserialize(&mut r).unwrap();
|
|
let _gm = u8::deserialize(&mut r).unwrap();
|
|
let _pgm = i8::deserialize(&mut r).unwrap();
|
|
let dc = VarInt::deserialize(&mut r).unwrap().0;
|
|
for _ in 0..dc {
|
|
let _dim = String::deserialize(&mut r).unwrap();
|
|
}
|
|
let _dim_codec: nbt::Blob = nbt::from_reader(&mut r).unwrap();
|
|
let init = r.position() as usize;
|
|
let _dim: nbt::Blob = nbt::from_reader(&mut r).unwrap();
|
|
let end = r.position() as usize;
|
|
std::io::stdout().lock().write_all(&packet[init..end]).unwrap();
|
|
}
|
|
|