diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | bot/src/main.rs | 2 | ||||
| -rw-r--r-- | minecraft-client/src/connect.rs | 17 | ||||
| -rw-r--r-- | minecraft-client/src/crypt.rs (renamed from minecraft-client/src/listeners/handshake.rs) | 0 | ||||
| -rw-r--r-- | minecraft-client/src/listeners/mod.rs | 3 | ||||
| -rw-r--r-- | minecraft-protocol/src/packets/login/clientbound_custom_query_packet.rs | 39 |
6 files changed, 54 insertions, 9 deletions
diff --git a/README.md b/README.md new file mode 100644 index 00000000..06f78a52 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# this library doesn't have a name yet idk what to call it + diff --git a/bot/src/main.rs b/bot/src/main.rs index ca5c698a..19959ce5 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -2,7 +2,7 @@ use minecraft_client::connect::join_server; use tokio::runtime::Runtime; async fn bot() { - let address = "localhost:62072"; + let address = "localhost:50388"; let _response = join_server(&address.try_into().unwrap()).await.unwrap(); // println!("{}", response.description.to_ansi(None)); println!("connected"); diff --git a/minecraft-client/src/connect.rs b/minecraft-client/src/connect.rs index 4bf937db..c4a18f1e 100644 --- a/minecraft-client/src/connect.rs +++ b/minecraft-client/src/connect.rs @@ -33,11 +33,18 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> { conn.write(ServerboundHelloPacket { username }.get()).await; // encryption request - let packet = conn.read().await.unwrap(); - let _encryption_request_packet = match packet { - LoginPacket::ClientboundHelloPacket(p) => p, - _ => return Err(format!("Invalid packet type: {:?}", packet)), - }; + loop { + let packet = conn.read().await.unwrap(); + match packet { + LoginPacket::ClientboundHelloPacket(encryption_request_packet) => { + println!( + "Got encryption request {:?} {:?}", + encryption_request_packet.nonce, encryption_request_packet.public_key + ); + } + _ => (), + } + } // TODO: client auth diff --git a/minecraft-client/src/listeners/handshake.rs b/minecraft-client/src/crypt.rs index e69de29b..e69de29b 100644 --- a/minecraft-client/src/listeners/handshake.rs +++ b/minecraft-client/src/crypt.rs diff --git a/minecraft-client/src/listeners/mod.rs b/minecraft-client/src/listeners/mod.rs deleted file mode 100644 index 1f174453..00000000 --- a/minecraft-client/src/listeners/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -trait PacketListener { - handle(Packet) -}
\ No newline at end of file diff --git a/minecraft-protocol/src/packets/login/clientbound_custom_query_packet.rs b/minecraft-protocol/src/packets/login/clientbound_custom_query_packet.rs new file mode 100644 index 00000000..54f3dd14 --- /dev/null +++ b/minecraft-protocol/src/packets/login/clientbound_custom_query_packet.rs @@ -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()) + } +} |
