mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
Merge branch 'declare-commands-packet'
This commit is contained in:
commit
65dd2eacc2
6 changed files with 100 additions and 34 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -117,6 +117,7 @@ dependencies = [
|
||||||
"async-recursion",
|
"async-recursion",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"azalea-auth",
|
"azalea-auth",
|
||||||
|
"azalea-brigadier",
|
||||||
"azalea-chat",
|
"azalea-chat",
|
||||||
"azalea-core",
|
"azalea-core",
|
||||||
"azalea-nbt",
|
"azalea-nbt",
|
||||||
|
|
|
@ -6,8 +6,8 @@ I named this Azalea because it sounds like a cool word and this is a cool librar
|
||||||
|
|
||||||
## Goals
|
## Goals
|
||||||
|
|
||||||
- Bypass most anticheats
|
|
||||||
- Only support the latest Minecraft version
|
|
||||||
- Do everything a vanilla client can do
|
- Do everything a vanilla client can do
|
||||||
- Be fast
|
|
||||||
- Be easy to use
|
- Be easy to use
|
||||||
|
- Bypass most/all anticheats
|
||||||
|
- Support the latest Minecraft version
|
||||||
|
- Be fast
|
||||||
|
|
|
@ -73,6 +73,9 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> {
|
||||||
GamePacket::ClientboundChangeDifficultyPacket(p) => {
|
GamePacket::ClientboundChangeDifficultyPacket(p) => {
|
||||||
println!("Got difficulty packet {:?}", p);
|
println!("Got difficulty packet {:?}", p);
|
||||||
}
|
}
|
||||||
|
GamePacket::ClientboundDeclareCommandsPacket(p) => {
|
||||||
|
println!("Got declare commands packet {:?}", p);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Error: {:?}", e);
|
println!("Error: {:?}", e);
|
||||||
|
|
|
@ -10,6 +10,7 @@ async-compression = {version = "^0.3.8", features = ["tokio", "zlib"]}
|
||||||
async-recursion = "^0.3.2"
|
async-recursion = "^0.3.2"
|
||||||
async-trait = "0.1.51"
|
async-trait = "0.1.51"
|
||||||
azalea-auth = {path = "../azalea-auth"}
|
azalea-auth = {path = "../azalea-auth"}
|
||||||
|
azalea-brigadier = {path = "../azalea-brigadier"}
|
||||||
azalea-chat = {path = "../azalea-chat"}
|
azalea-chat = {path = "../azalea-chat"}
|
||||||
azalea-core = {path = "../azalea-core"}
|
azalea-core = {path = "../azalea-core"}
|
||||||
azalea-nbt = {path = "../azalea-nbt"}
|
azalea-nbt = {path = "../azalea-nbt"}
|
||||||
|
|
|
@ -1,37 +1,96 @@
|
||||||
// use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
// use crate::mc_buf::Readable;
|
use async_trait::async_trait;
|
||||||
|
use tokio::io::AsyncRead;
|
||||||
|
|
||||||
// use super::LoginPacket;
|
use crate::mc_buf::{McBufReadable, Readable};
|
||||||
|
|
||||||
// #[derive(Hash, Clone, Debug)]
|
use super::GamePacket;
|
||||||
// pub struct ClientboundDeclareCommandsPacket {
|
|
||||||
// pub root: RootCommandNode<SharedSuggestionProvider>,
|
|
||||||
// pub public_key: Vec<u8>,
|
|
||||||
// pub nonce: Vec<u8>,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// impl ClientboundHelloPacket {
|
#[derive(Hash, Clone, Debug)]
|
||||||
// pub fn get(self) -> LoginPacket {
|
pub struct ClientboundDeclareCommandsPacket {
|
||||||
// LoginPacket::ClientboundHelloPacket(self)
|
pub entries: Vec<BrigadierNodeStub>,
|
||||||
// }
|
pub root_index: i32,
|
||||||
|
}
|
||||||
|
|
||||||
// pub fn write(&self, _buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
|
impl ClientboundDeclareCommandsPacket {
|
||||||
// panic!("ClientboundHelloPacket::write not implemented")
|
pub fn get(self) -> GamePacket {
|
||||||
// }
|
GamePacket::ClientboundDeclareCommandsPacket(self)
|
||||||
|
}
|
||||||
|
|
||||||
// pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
|
pub fn write(&self, _buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
|
||||||
// buf: &mut T,
|
panic!("ClientboundDeclareCommandsPacket::write not implemented")
|
||||||
// ) -> Result<LoginPacket, String> {
|
}
|
||||||
// let server_id = buf.read_utf_with_len(20).await?;
|
|
||||||
// let public_key = buf.read_byte_array().await?;
|
|
||||||
// let nonce = buf.read_byte_array().await?;
|
|
||||||
|
|
||||||
// Ok(ClientboundHelloPacket {
|
pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
|
||||||
// server_id,
|
buf: &mut T,
|
||||||
// public_key,
|
) -> Result<GamePacket, String> {
|
||||||
// nonce,
|
let node_count = buf.read_varint().await?;
|
||||||
// }
|
println!("node_count: {}", node_count);
|
||||||
// .get())
|
let mut nodes = Vec::with_capacity(node_count as usize);
|
||||||
// }
|
for _ in 0..node_count {
|
||||||
// }
|
let node = BrigadierNodeStub::read_into(buf).await?;
|
||||||
|
nodes.push(node);
|
||||||
|
}
|
||||||
|
let root_index = buf.read_varint().await?;
|
||||||
|
Ok(GamePacket::ClientboundDeclareCommandsPacket(
|
||||||
|
ClientboundDeclareCommandsPacket {
|
||||||
|
entries: nodes,
|
||||||
|
root_index,
|
||||||
|
},
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Hash, Debug, Clone)]
|
||||||
|
pub struct BrigadierNodeStub {}
|
||||||
|
|
||||||
|
// azalea_brigadier::tree::CommandNode
|
||||||
|
#[async_trait]
|
||||||
|
impl McBufReadable for BrigadierNodeStub {
|
||||||
|
async fn read_into<R>(buf: &mut R) -> Result<Self, String>
|
||||||
|
where
|
||||||
|
R: AsyncRead + std::marker::Unpin + std::marker::Send,
|
||||||
|
{
|
||||||
|
let flags = u8::read_into(buf).await?;
|
||||||
|
|
||||||
|
let node_type = flags & 0x03;
|
||||||
|
let is_executable = flags & 0x04 != 0;
|
||||||
|
let has_redirect = flags & 0x08 != 0;
|
||||||
|
let has_suggestions_type = flags & 0x10 != 0;
|
||||||
|
println!("flags: {}, node_type: {}, is_executable: {}, has_redirect: {}, has_suggestions_type: {}", flags, node_type, is_executable, has_redirect, has_suggestions_type);
|
||||||
|
|
||||||
|
let children = buf.read_int_id_list().await?;
|
||||||
|
println!("children: {:?}", children);
|
||||||
|
let redirect_node = if has_redirect {
|
||||||
|
buf.read_varint().await?
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
println!("redirect_node: {}", redirect_node);
|
||||||
|
|
||||||
|
if node_type == 2 {
|
||||||
|
let name = buf.read_utf().await?;
|
||||||
|
println!("name: {}", name);
|
||||||
|
|
||||||
|
let resource_location = if has_suggestions_type {
|
||||||
|
Some(buf.read_resource_location().await?)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
println!(
|
||||||
|
"node_type=2, flags={}, name={}, resource_location={:?}",
|
||||||
|
flags, name, resource_location
|
||||||
|
);
|
||||||
|
return Ok(BrigadierNodeStub {});
|
||||||
|
}
|
||||||
|
if node_type == 1 {
|
||||||
|
let name = buf.read_utf().await?;
|
||||||
|
println!("node_type=1, flags={}, name={}", flags, name);
|
||||||
|
return Ok(BrigadierNodeStub {});
|
||||||
|
}
|
||||||
|
println!("node_type={}, flags={}", node_type, flags);
|
||||||
|
Ok(BrigadierNodeStub {})
|
||||||
|
// return Err("Unknown node type".to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
pub mod clientbound_change_difficulty_packet;
|
pub mod clientbound_change_difficulty_packet;
|
||||||
pub mod clientbound_custom_payload_packet;
|
pub mod clientbound_custom_payload_packet;
|
||||||
|
pub mod clientbound_declare_commands_packet;
|
||||||
pub mod clientbound_login_packet;
|
pub mod clientbound_login_packet;
|
||||||
pub mod clientbound_update_view_distance_packet;
|
pub mod clientbound_update_view_distance_packet;
|
||||||
|
|
||||||
|
@ -10,8 +11,9 @@ declare_state_packets!(
|
||||||
Serverbound => {},
|
Serverbound => {},
|
||||||
Clientbound => {
|
Clientbound => {
|
||||||
0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket,
|
0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket,
|
||||||
|
0x12: clientbound_declare_commands_packet::ClientboundDeclareCommandsPacket,
|
||||||
0x18: clientbound_custom_payload_packet::ClientboundCustomPayloadPacket,
|
0x18: clientbound_custom_payload_packet::ClientboundCustomPayloadPacket,
|
||||||
0x26: clientbound_login_packet::ClientboundLoginPacket,
|
0x26: clientbound_login_packet::ClientboundLoginPacket,
|
||||||
0x4a: clientbound_update_view_distance_packet::ClientboundUpdateViewDistancePacket,
|
0x4a: clientbound_update_view_distance_packet::ClientboundUpdateViewDistancePacket
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue