mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 23:44:38 +00:00
start implementing other packets and stuff
This commit is contained in:
parent
1c9e089b72
commit
2e11f5a564
6 changed files with 54 additions and 9 deletions
2
README.md
Normal file
2
README.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# this library doesn't have a name yet idk what to call it
|
||||||
|
|
|
@ -2,7 +2,7 @@ use minecraft_client::connect::join_server;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
async fn bot() {
|
async fn bot() {
|
||||||
let address = "localhost:62072";
|
let address = "localhost:50388";
|
||||||
let _response = join_server(&address.try_into().unwrap()).await.unwrap();
|
let _response = join_server(&address.try_into().unwrap()).await.unwrap();
|
||||||
// println!("{}", response.description.to_ansi(None));
|
// println!("{}", response.description.to_ansi(None));
|
||||||
println!("connected");
|
println!("connected");
|
||||||
|
|
|
@ -33,11 +33,18 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> {
|
||||||
conn.write(ServerboundHelloPacket { username }.get()).await;
|
conn.write(ServerboundHelloPacket { username }.get()).await;
|
||||||
|
|
||||||
// encryption request
|
// encryption request
|
||||||
|
loop {
|
||||||
let packet = conn.read().await.unwrap();
|
let packet = conn.read().await.unwrap();
|
||||||
let _encryption_request_packet = match packet {
|
match packet {
|
||||||
LoginPacket::ClientboundHelloPacket(p) => p,
|
LoginPacket::ClientboundHelloPacket(encryption_request_packet) => {
|
||||||
_ => return Err(format!("Invalid packet type: {:?}", packet)),
|
println!(
|
||||||
};
|
"Got encryption request {:?} {:?}",
|
||||||
|
encryption_request_packet.nonce, encryption_request_packet.public_key
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: client auth
|
// TODO: client auth
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
trait PacketListener {
|
|
||||||
handle(Packet)
|
|
||||||
}
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
use std::hash::Hash;
|
||||||
|
use tokio::io::BufReader;
|
||||||
|
|
||||||
|
use crate::mc_buf;
|
||||||
|
|
||||||
|
use super::LoginPacket;
|
||||||
|
|
||||||
|
#[derive(Hash, Clone, Debug)]
|
||||||
|
pub struct ClientboundCustomQueryPacket {
|
||||||
|
pub transacton_id: u32,
|
||||||
|
// TODO: this should be a resource location
|
||||||
|
pub identifier: String,
|
||||||
|
pub data: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ClientboundHelloPacket {
|
||||||
|
pub fn get(self) -> LoginPacket {
|
||||||
|
LoginPacket::ClientboundHelloPacket(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn write(&self, _buf: &mut Vec<u8>) {
|
||||||
|
panic!("ClientboundHelloPacket::write not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
|
||||||
|
buf: &mut BufReader<T>,
|
||||||
|
) -> Result<LoginPacket, String> {
|
||||||
|
// let server_id = mc_buf::read_utf_with_len(buf, 20).await?;
|
||||||
|
// let public_key = mc_buf::read_byte_array(buf).await?;
|
||||||
|
// let nonce = mc_buf::read_byte_array(buf).await?;
|
||||||
|
|
||||||
|
// Ok(ClientboundHelloPacket {
|
||||||
|
// server_id,
|
||||||
|
// public_key,
|
||||||
|
// nonce,
|
||||||
|
// }
|
||||||
|
// .get())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue