mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
Split clientbound and serverbound packets
This commit is contained in:
parent
aadf2de3cb
commit
4ee4687053
80 changed files with 324 additions and 278 deletions
|
@ -40,24 +40,56 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke
|
||||||
contents.into()
|
contents.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[proc_macro_derive(GamePacket, attributes(var))]
|
#[proc_macro_derive(ServerboundGamePacket, attributes(var))]
|
||||||
pub fn derive_game_packet(input: TokenStream) -> TokenStream {
|
pub fn derive_serverbound_game_packet(input: TokenStream) -> TokenStream {
|
||||||
as_packet_derive(input, quote! {crate::packets::game::GamePacket})
|
as_packet_derive(input, quote! {crate::packets::game::ServerboundGamePacket})
|
||||||
|
}
|
||||||
|
#[proc_macro_derive(ServerboundHandshakePacket, attributes(var))]
|
||||||
|
pub fn derive_serverbound_handshake_packet(input: TokenStream) -> TokenStream {
|
||||||
|
as_packet_derive(
|
||||||
|
input,
|
||||||
|
quote! {crate::packets::handshake::ServerboundHandshakePacket},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
#[proc_macro_derive(ServerboundLoginPacket, attributes(var))]
|
||||||
|
pub fn derive_serverbound_login_packet(input: TokenStream) -> TokenStream {
|
||||||
|
as_packet_derive(
|
||||||
|
input,
|
||||||
|
quote! {crate::packets::login::ServerboundLoginPacket},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
#[proc_macro_derive(ServerboundStatusPacket, attributes(var))]
|
||||||
|
pub fn derive_serverbound_status_packet(input: TokenStream) -> TokenStream {
|
||||||
|
as_packet_derive(
|
||||||
|
input,
|
||||||
|
quote! {crate::packets::status::ServerboundStatusPacket},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[proc_macro_derive(HandshakePacket, attributes(var))]
|
#[proc_macro_derive(ClientboundGamePacket, attributes(var))]
|
||||||
pub fn derive_handshake_packet(input: TokenStream) -> TokenStream {
|
pub fn derive_clientbound_game_packet(input: TokenStream) -> TokenStream {
|
||||||
as_packet_derive(input, quote! {crate::packets::handshake::HandshakePacket})
|
as_packet_derive(input, quote! {crate::packets::game::ClientboundGamePacket})
|
||||||
}
|
}
|
||||||
|
#[proc_macro_derive(ClientboundHandshakePacket, attributes(var))]
|
||||||
#[proc_macro_derive(LoginPacket, attributes(var))]
|
pub fn derive_clientbound_handshake_packet(input: TokenStream) -> TokenStream {
|
||||||
pub fn derive_login_packet(input: TokenStream) -> TokenStream {
|
as_packet_derive(
|
||||||
as_packet_derive(input, quote! {crate::packets::login::LoginPacket})
|
input,
|
||||||
|
quote! {crate::packets::handshake::ClientboundHandshakePacket},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
#[proc_macro_derive(ClientboundLoginPacket, attributes(var))]
|
||||||
#[proc_macro_derive(StatusPacket, attributes(var))]
|
pub fn derive_clientbound_login_packet(input: TokenStream) -> TokenStream {
|
||||||
pub fn derive_status_packet(input: TokenStream) -> TokenStream {
|
as_packet_derive(
|
||||||
as_packet_derive(input, quote! {crate::packets::status::StatusPacket})
|
input,
|
||||||
|
quote! {crate::packets::login::ClientboundLoginPacket},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
#[proc_macro_derive(ClientboundStatusPacket, attributes(var))]
|
||||||
|
pub fn derive_clientbound_status_packet(input: TokenStream) -> TokenStream {
|
||||||
|
as_packet_derive(
|
||||||
|
input,
|
||||||
|
quote! {crate::packets::status::ClientboundStatusPacket},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -154,23 +186,34 @@ impl Parse for DeclareStatePackets {
|
||||||
pub fn declare_state_packets(input: TokenStream) -> TokenStream {
|
pub fn declare_state_packets(input: TokenStream) -> TokenStream {
|
||||||
let input = parse_macro_input!(input as DeclareStatePackets);
|
let input = parse_macro_input!(input as DeclareStatePackets);
|
||||||
|
|
||||||
let state_name = input.name;
|
let serverbound_state_name =
|
||||||
let state_name_litstr = syn::LitStr::new(&state_name.to_string(), state_name.span());
|
Ident::new(&format!("Serverbound{}", input.name), input.name.span());
|
||||||
|
let clientbound_state_name =
|
||||||
|
Ident::new(&format!("Clientbound{}", input.name), input.name.span());
|
||||||
|
|
||||||
let mut enum_contents = quote!();
|
let state_name_litstr = syn::LitStr::new(&input.name.to_string(), input.name.span());
|
||||||
let mut id_match_contents = quote!();
|
|
||||||
let mut write_match_contents = quote!();
|
let has_serverbound_packets = !input.serverbound.packets.is_empty();
|
||||||
|
let has_clientbound_packets = !input.clientbound.packets.is_empty();
|
||||||
|
|
||||||
|
let mut serverbound_enum_contents = quote!();
|
||||||
|
let mut clientbound_enum_contents = quote!();
|
||||||
|
let mut serverbound_id_match_contents = quote!();
|
||||||
|
let mut clientbound_id_match_contents = quote!();
|
||||||
|
let mut serverbound_write_match_contents = quote!();
|
||||||
|
let mut clientbound_write_match_contents = quote!();
|
||||||
let mut serverbound_read_match_contents = quote!();
|
let mut serverbound_read_match_contents = quote!();
|
||||||
let mut clientbound_read_match_contents = quote!();
|
let mut clientbound_read_match_contents = quote!();
|
||||||
|
|
||||||
for PacketIdPair { id, module, name } in input.serverbound.packets {
|
for PacketIdPair { id, module, name } in input.serverbound.packets {
|
||||||
enum_contents.extend(quote! {
|
serverbound_enum_contents.extend(quote! {
|
||||||
#name(#module::#name),
|
#name(#module::#name),
|
||||||
});
|
});
|
||||||
id_match_contents.extend(quote! {
|
serverbound_id_match_contents.extend(quote! {
|
||||||
#state_name::#name(_packet) => #id,
|
#serverbound_state_name::#name(_packet) => #id,
|
||||||
});
|
});
|
||||||
write_match_contents.extend(quote! {
|
serverbound_write_match_contents.extend(quote! {
|
||||||
#state_name::#name(packet) => packet.write(buf),
|
#serverbound_state_name::#name(packet) => packet.write(buf),
|
||||||
});
|
});
|
||||||
serverbound_read_match_contents.extend(quote! {
|
serverbound_read_match_contents.extend(quote! {
|
||||||
#id => #module::#name::read(buf)?,
|
#id => #module::#name::read(buf)?,
|
||||||
|
@ -178,63 +221,100 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
|
||||||
}
|
}
|
||||||
for PacketIdPair { id, module, name } in input.clientbound.packets {
|
for PacketIdPair { id, module, name } in input.clientbound.packets {
|
||||||
// let name_litstr = syn::LitStr::new(&name.to_string(), name.span());
|
// let name_litstr = syn::LitStr::new(&name.to_string(), name.span());
|
||||||
enum_contents.extend(quote! {
|
clientbound_enum_contents.extend(quote! {
|
||||||
#name(#module::#name),
|
#name(#module::#name),
|
||||||
});
|
});
|
||||||
id_match_contents.extend(quote! {
|
clientbound_id_match_contents.extend(quote! {
|
||||||
#state_name::#name(_packet) => #id,
|
#clientbound_state_name::#name(_packet) => #id,
|
||||||
});
|
});
|
||||||
write_match_contents.extend(quote! {
|
clientbound_write_match_contents.extend(quote! {
|
||||||
#state_name::#name(packet) => packet.write(buf),
|
#clientbound_state_name::#name(packet) => packet.write(buf),
|
||||||
});
|
});
|
||||||
clientbound_read_match_contents.extend(quote! {
|
clientbound_read_match_contents.extend(quote! {
|
||||||
#id => #module::#name::read(buf)?,
|
#id => #module::#name::read(buf)?,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
quote! {
|
let mut contents = quote! {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum #state_name
|
pub enum #serverbound_state_name
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
#enum_contents
|
#serverbound_enum_contents
|
||||||
}
|
}
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub enum #clientbound_state_name
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
#clientbound_enum_contents
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
impl crate::packets::ProtocolPacket for #state_name {
|
contents.extend(quote!{
|
||||||
|
impl crate::packets::ProtocolPacket for #serverbound_state_name {
|
||||||
fn id(&self) -> u32 {
|
fn id(&self) -> u32 {
|
||||||
match self {
|
match self {
|
||||||
#id_match_contents
|
#serverbound_id_match_contents
|
||||||
|
_ => panic!("Impossible state, this packet shouldn't exist.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
|
fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
|
||||||
match self {
|
match self {
|
||||||
#write_match_contents
|
#serverbound_write_match_contents
|
||||||
|
_ => panic!("Impossible state, this packet shouldn't exist.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read a packet by its id, ConnectionProtocol, and flow
|
/// Read a packet by its id, ConnectionProtocol, and flow
|
||||||
fn read(
|
fn read(
|
||||||
id: u32,
|
id: u32,
|
||||||
flow: &crate::connect::PacketFlow,
|
|
||||||
buf: &mut impl std::io::Read,
|
buf: &mut impl std::io::Read,
|
||||||
) -> Result<#state_name, String>
|
) -> Result<#serverbound_state_name, String>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
Ok(match flow {
|
Ok(match id {
|
||||||
crate::connect::PacketFlow::ServerToClient => match id {
|
|
||||||
#clientbound_read_match_contents
|
|
||||||
_ => return Err(format!("Unknown ServerToClient {} packet id: {}", #state_name_litstr, id)),
|
|
||||||
},
|
|
||||||
crate::connect::PacketFlow::ClientToServer => match id {
|
|
||||||
#serverbound_read_match_contents
|
#serverbound_read_match_contents
|
||||||
_ => return Err(format!("Unknown ClientToServer {} packet id: {}", #state_name_litstr, id)),
|
_ => return Err(format!("Unknown Serverbound {} packet id: {}", #state_name_litstr, id)),
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
contents.extend(quote!{
|
||||||
|
impl crate::packets::ProtocolPacket for #clientbound_state_name {
|
||||||
|
fn id(&self) -> u32 {
|
||||||
|
match self {
|
||||||
|
#clientbound_id_match_contents
|
||||||
|
_ => panic!("Impossible state, this packet shouldn't exist.")
|
||||||
}
|
}
|
||||||
.into()
|
}
|
||||||
|
|
||||||
|
fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
|
||||||
|
match self {
|
||||||
|
#clientbound_write_match_contents
|
||||||
|
_ => panic!("Impossible state, this packet shouldn't exist.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Read a packet by its id, ConnectionProtocol, and flow
|
||||||
|
fn read(
|
||||||
|
id: u32,
|
||||||
|
buf: &mut impl std::io::Read,
|
||||||
|
) -> Result<#clientbound_state_name, String>
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
Ok(match id {
|
||||||
|
#clientbound_read_match_contents
|
||||||
|
_ => return Err(format!("Unknown Clientbound {} packet id: {}", #state_name_litstr, id)),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
contents.into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,21 @@
|
||||||
//! parse sending and receiving packets with a server.
|
//! parse sending and receiving packets with a server.
|
||||||
|
|
||||||
use crate::packets::game::GamePacket;
|
use crate::packets::game::{ClientboundGamePacket, ServerboundGamePacket};
|
||||||
use crate::packets::handshake::HandshakePacket;
|
use crate::packets::handshake::{ClientboundHandshakePacket, ServerboundHandshakePacket};
|
||||||
use crate::packets::login::LoginPacket;
|
use crate::packets::login::{ClientboundLoginPacket, ServerboundLoginPacket};
|
||||||
use crate::packets::status::StatusPacket;
|
use crate::packets::status::{ClientboundStatusPacket, ServerboundStatusPacket};
|
||||||
use crate::read::read_packet;
|
use crate::read::read_packet;
|
||||||
use crate::write::write_packet;
|
use crate::write::write_packet;
|
||||||
use crate::ServerIpAddress;
|
use crate::ServerIpAddress;
|
||||||
use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc};
|
use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc};
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub enum PacketFlow {
|
|
||||||
ClientToServer,
|
|
||||||
ServerToClient,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct HandshakeConnection {
|
pub struct HandshakeConnection {
|
||||||
pub flow: PacketFlow,
|
|
||||||
/// The buffered writer
|
/// The buffered writer
|
||||||
pub stream: TcpStream,
|
pub stream: TcpStream,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GameConnection {
|
pub struct GameConnection {
|
||||||
pub flow: PacketFlow,
|
|
||||||
/// The buffered writer
|
/// The buffered writer
|
||||||
pub stream: TcpStream,
|
pub stream: TcpStream,
|
||||||
pub compression_threshold: Option<u32>,
|
pub compression_threshold: Option<u32>,
|
||||||
|
@ -32,13 +24,11 @@ pub struct GameConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct StatusConnection {
|
pub struct StatusConnection {
|
||||||
pub flow: PacketFlow,
|
|
||||||
/// The buffered writer
|
/// The buffered writer
|
||||||
pub stream: TcpStream,
|
pub stream: TcpStream,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LoginConnection {
|
pub struct LoginConnection {
|
||||||
pub flow: PacketFlow,
|
|
||||||
/// The buffered writer
|
/// The buffered writer
|
||||||
pub stream: TcpStream,
|
pub stream: TcpStream,
|
||||||
pub compression_threshold: Option<u32>,
|
pub compression_threshold: Option<u32>,
|
||||||
|
@ -60,15 +50,11 @@ impl HandshakeConnection {
|
||||||
.set_nodelay(true)
|
.set_nodelay(true)
|
||||||
.expect("Error enabling tcp_nodelay");
|
.expect("Error enabling tcp_nodelay");
|
||||||
|
|
||||||
Ok(HandshakeConnection {
|
Ok(HandshakeConnection { stream })
|
||||||
flow: PacketFlow::ServerToClient,
|
|
||||||
stream,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn login(self) -> LoginConnection {
|
pub fn login(self) -> LoginConnection {
|
||||||
LoginConnection {
|
LoginConnection {
|
||||||
flow: self.flow,
|
|
||||||
stream: self.stream,
|
stream: self.stream,
|
||||||
compression_threshold: None,
|
compression_threshold: None,
|
||||||
enc_cipher: None,
|
enc_cipher: None,
|
||||||
|
@ -78,25 +64,23 @@ impl HandshakeConnection {
|
||||||
|
|
||||||
pub fn status(self) -> StatusConnection {
|
pub fn status(self) -> StatusConnection {
|
||||||
StatusConnection {
|
StatusConnection {
|
||||||
flow: self.flow,
|
|
||||||
stream: self.stream,
|
stream: self.stream,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn read(&mut self) -> Result<HandshakePacket, String> {
|
pub async fn read(&mut self) -> Result<ClientboundHandshakePacket, String> {
|
||||||
read_packet::<HandshakePacket, _>(&self.flow, &mut self.stream, None, &mut None).await
|
read_packet::<ClientboundHandshakePacket, _>(&mut self.stream, None, &mut None).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write a packet to the server
|
/// Write a packet to the server
|
||||||
pub async fn write(&mut self, packet: HandshakePacket) {
|
pub async fn write(&mut self, packet: ServerboundHandshakePacket) {
|
||||||
write_packet(packet, &mut self.stream, None, &mut None).await;
|
write_packet(packet, &mut self.stream, None, &mut None).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GameConnection {
|
impl GameConnection {
|
||||||
pub async fn read(&mut self) -> Result<GamePacket, String> {
|
pub async fn read(&mut self) -> Result<ClientboundGamePacket, String> {
|
||||||
read_packet::<GamePacket, _>(
|
read_packet::<ClientboundGamePacket, _>(
|
||||||
&self.flow,
|
|
||||||
&mut self.stream,
|
&mut self.stream,
|
||||||
self.compression_threshold,
|
self.compression_threshold,
|
||||||
&mut self.dec_cipher,
|
&mut self.dec_cipher,
|
||||||
|
@ -105,7 +89,7 @@ impl GameConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write a packet to the server
|
/// Write a packet to the server
|
||||||
pub async fn write(&mut self, packet: GamePacket) {
|
pub async fn write(&mut self, packet: ServerboundGamePacket) {
|
||||||
write_packet(
|
write_packet(
|
||||||
packet,
|
packet,
|
||||||
&mut self.stream,
|
&mut self.stream,
|
||||||
|
@ -117,20 +101,19 @@ impl GameConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StatusConnection {
|
impl StatusConnection {
|
||||||
pub async fn read(&mut self) -> Result<StatusPacket, String> {
|
pub async fn read(&mut self) -> Result<ClientboundStatusPacket, String> {
|
||||||
read_packet::<StatusPacket, _>(&self.flow, &mut self.stream, None, &mut None).await
|
read_packet::<ClientboundStatusPacket, _>(&mut self.stream, None, &mut None).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write a packet to the server
|
/// Write a packet to the server
|
||||||
pub async fn write(&mut self, packet: StatusPacket) {
|
pub async fn write(&mut self, packet: ServerboundStatusPacket) {
|
||||||
write_packet(packet, &mut self.stream, None, &mut None).await;
|
write_packet(packet, &mut self.stream, None, &mut None).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoginConnection {
|
impl LoginConnection {
|
||||||
pub async fn read(&mut self) -> Result<LoginPacket, String> {
|
pub async fn read(&mut self) -> Result<ClientboundLoginPacket, String> {
|
||||||
read_packet::<LoginPacket, _>(
|
read_packet::<ClientboundLoginPacket, _>(
|
||||||
&self.flow,
|
|
||||||
&mut self.stream,
|
&mut self.stream,
|
||||||
self.compression_threshold,
|
self.compression_threshold,
|
||||||
&mut self.dec_cipher,
|
&mut self.dec_cipher,
|
||||||
|
@ -139,7 +122,7 @@ impl LoginConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write a packet to the server
|
/// Write a packet to the server
|
||||||
pub async fn write(&mut self, packet: LoginPacket) {
|
pub async fn write(&mut self, packet: ServerboundLoginPacket) {
|
||||||
write_packet(
|
write_packet(
|
||||||
packet,
|
packet,
|
||||||
&mut self.stream,
|
&mut self.stream,
|
||||||
|
@ -167,7 +150,6 @@ impl LoginConnection {
|
||||||
|
|
||||||
pub fn game(self) -> GameConnection {
|
pub fn game(self) -> GameConnection {
|
||||||
GameConnection {
|
GameConnection {
|
||||||
flow: self.flow,
|
|
||||||
stream: self.stream,
|
stream: self.stream,
|
||||||
compression_threshold: self.compression_threshold,
|
compression_threshold: self.compression_threshold,
|
||||||
enc_cipher: self.enc_cipher,
|
enc_cipher: self.enc_cipher,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::EntityPos;
|
use azalea_core::EntityPos;
|
||||||
use azalea_entity::Entity;
|
use azalea_entity::Entity;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundAddEntityPacket {
|
pub struct ClientboundAddEntityPacket {
|
||||||
/// The id of the entity.
|
/// The id of the entity.
|
||||||
#[var]
|
#[var]
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::EntityPos;
|
use azalea_core::EntityPos;
|
||||||
use azalea_entity::Entity;
|
use azalea_entity::Entity;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
/// This packet is sent by the server when a player comes into visible range, not when a player joins.
|
/// This packet is sent by the server when a player comes into visible range, not when a player joins.
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundAddPlayerPacket {
|
pub struct ClientboundAddPlayerPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundAnimatePacket {
|
pub struct ClientboundAnimatePacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundBlockChangedAckPacket {
|
pub struct ClientboundBlockChangedAckPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub sequence: i32,
|
pub sequence: i32,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::BlockPos;
|
use azalea_core::BlockPos;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundBlockUpdatePacket {
|
pub struct ClientboundBlockUpdatePacket {
|
||||||
pub pos: BlockPos,
|
pub pos: BlockPos,
|
||||||
// TODO: in vanilla this is a BlockState, but here we just have it as a number.
|
// TODO: in vanilla this is a BlockState, but here we just have it as a number.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::Difficulty;
|
use azalea_core::Difficulty;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundChangeDifficultyPacket {
|
pub struct ClientboundChangeDifficultyPacket {
|
||||||
pub difficulty: Difficulty,
|
pub difficulty: Difficulty,
|
||||||
pub locked: bool,
|
pub locked: bool,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::component::Component;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundChatPreviewPacket {
|
pub struct ClientboundChatPreviewPacket {
|
||||||
pub query_id: i32,
|
pub query_id: i32,
|
||||||
pub preview: Option<Component>,
|
pub preview: Option<Component>,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::Slot;
|
use azalea_core::Slot;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundContainerSetContentPacket {
|
pub struct ClientboundContainerSetContentPacket {
|
||||||
pub container_id: u8,
|
pub container_id: u8,
|
||||||
#[var]
|
#[var]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundCustomChatCompletionsPacket {
|
pub struct ClientboundCustomChatCompletionsPacket {
|
||||||
pub action: Action,
|
pub action: Action,
|
||||||
pub entries: Vec<String>,
|
pub entries: Vec<String>,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_buf::UnsizedByteArray;
|
use azalea_buf::UnsizedByteArray;
|
||||||
use azalea_core::ResourceLocation;
|
use azalea_core::ResourceLocation;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundCustomPayloadPacket {
|
pub struct ClientboundCustomPayloadPacket {
|
||||||
pub identifier: ResourceLocation,
|
pub identifier: ResourceLocation,
|
||||||
pub data: UnsizedByteArray,
|
pub data: UnsizedByteArray,
|
||||||
|
|
|
@ -2,13 +2,13 @@ use azalea_buf::McBuf;
|
||||||
use azalea_buf::McBufVarReadable;
|
use azalea_buf::McBufVarReadable;
|
||||||
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
||||||
use azalea_core::ResourceLocation;
|
use azalea_core::ResourceLocation;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::{
|
use std::{
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundDeclareCommandsPacket {
|
pub struct ClientboundDeclareCommandsPacket {
|
||||||
pub entries: Vec<BrigadierNodeStub>,
|
pub entries: Vec<BrigadierNodeStub>,
|
||||||
#[var]
|
#[var]
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_crypto::MessageSignature;
|
use azalea_crypto::MessageSignature;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundDeleteChatPacket {
|
pub struct ClientboundDeleteChatPacket {
|
||||||
pub message_signature: MessageSignature,
|
pub message_signature: MessageSignature,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::component::Component;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundDisconnectPacket {
|
pub struct ClientboundDisconnectPacket {
|
||||||
pub reason: Component,
|
pub reason: Component,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
// we can't identify the status in azalea-protocol since they vary depending on the entity
|
// we can't identify the status in azalea-protocol since they vary depending on the entity
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundEntityEventPacket {
|
pub struct ClientboundEntityEventPacket {
|
||||||
pub entity_id: u32,
|
pub entity_id: u32,
|
||||||
pub event_id: u8,
|
pub event_id: u8,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundEntityVelocityPacket {
|
pub struct ClientboundEntityVelocityPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: u32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundGameEventPacket {
|
pub struct ClientboundGameEventPacket {
|
||||||
pub event: EventType,
|
pub event: EventType,
|
||||||
pub param: f32,
|
pub param: f32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundInitializeBorderPacket {
|
pub struct ClientboundInitializeBorderPacket {
|
||||||
pub new_center_x: f64,
|
pub new_center_x: f64,
|
||||||
pub new_center_z: f64,
|
pub new_center_z: f64,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundKeepAlivePacket {
|
pub struct ClientboundKeepAlivePacket {
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
use super::clientbound_light_update_packet::ClientboundLightUpdatePacketData;
|
use super::clientbound_light_update_packet::ClientboundLightUpdatePacketData;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundLevelChunkWithLightPacket {
|
pub struct ClientboundLevelChunkWithLightPacket {
|
||||||
pub x: i32,
|
pub x: i32,
|
||||||
pub z: i32,
|
pub z: i32,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::BlockPos;
|
use azalea_core::BlockPos;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundLevelEventPacket {
|
pub struct ClientboundLevelEventPacket {
|
||||||
pub type_: i32,
|
pub type_: i32,
|
||||||
pub pos: BlockPos,
|
pub pos: BlockPos,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use azalea_buf::{McBufReadable, McBufVarReadable, McBufWritable};
|
use azalea_buf::{McBufReadable, McBufVarReadable, McBufWritable};
|
||||||
use azalea_core::ParticleData;
|
use azalea_core::ParticleData;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
#[derive(Clone, Debug, GamePacket)]
|
#[derive(Clone, Debug, ClientboundGamePacket)]
|
||||||
pub struct ClientboundLevelParticlesPacket {
|
pub struct ClientboundLevelParticlesPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub particle_id: u32,
|
pub particle_id: u32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::{BitSet, McBuf};
|
use azalea_buf::{BitSet, McBuf};
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundLightUpdatePacket {
|
pub struct ClientboundLightUpdatePacket {
|
||||||
pub x: i32,
|
pub x: i32,
|
||||||
pub z: i32,
|
pub z: i32,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::{GameType, GlobalPos, OptionalGameType, ResourceLocation};
|
use azalea_core::{GameType, GlobalPos, OptionalGameType, ResourceLocation};
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundLoginPacket {
|
pub struct ClientboundLoginPacket {
|
||||||
pub player_id: u32,
|
pub player_id: u32,
|
||||||
pub hardcore: bool,
|
pub hardcore: bool,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::PositionDelta8;
|
use azalea_core::PositionDelta8;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundMoveEntityPosPacket {
|
pub struct ClientboundMoveEntityPosPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: u32,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::PositionDelta8;
|
use azalea_core::PositionDelta8;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
/// This packet is sent by the server when an entity moves less then 8 blocks.
|
/// This packet is sent by the server when an entity moves less then 8 blocks.
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundMoveEntityPosrotPacket {
|
pub struct ClientboundMoveEntityPosrotPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: u32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundMoveEntityRotPacket {
|
pub struct ClientboundMoveEntityRotPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: i32,
|
pub entity_id: i32,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_buf::{McBufReadable, McBufWritable, Readable};
|
use azalea_buf::{McBufReadable, McBufWritable, Readable};
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPlayerAbilitiesPacket {
|
pub struct ClientboundPlayerAbilitiesPacket {
|
||||||
pub flags: PlayerAbilitiesFlags,
|
pub flags: PlayerAbilitiesFlags,
|
||||||
pub flying_speed: f32,
|
pub flying_speed: f32,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_crypto::{MessageSignature, SignedMessageHeader};
|
use azalea_crypto::{MessageSignature, SignedMessageHeader};
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPlayerChatHeaderPacket {
|
pub struct ClientboundPlayerChatHeaderPacket {
|
||||||
pub header: SignedMessageHeader,
|
pub header: SignedMessageHeader,
|
||||||
pub header_signature: MessageSignature,
|
pub header_signature: MessageSignature,
|
||||||
|
|
|
@ -2,11 +2,11 @@ use azalea_buf::{BitSet, McBuf, McBufReadable, McBufVarWritable};
|
||||||
use azalea_buf::{McBufVarReadable, McBufWritable};
|
use azalea_buf::{McBufVarReadable, McBufWritable};
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::component::Component;
|
||||||
use azalea_crypto::{MessageSignature, SignedMessageHeader};
|
use azalea_crypto::{MessageSignature, SignedMessageHeader};
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPlayerChatPacket {
|
pub struct ClientboundPlayerChatPacket {
|
||||||
pub message: PlayerChatMessage,
|
pub message: PlayerChatMessage,
|
||||||
pub chat_type: ChatTypeBound,
|
pub chat_type: ChatTypeBound,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::component::Component;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPlayerInfoPacket {
|
pub struct ClientboundPlayerInfoPacket {
|
||||||
pub action: Action,
|
pub action: Action,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_buf::{McBufReadable, McBufWritable, Readable};
|
use azalea_buf::{McBufReadable, McBufWritable, Readable};
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPlayerPositionPacket {
|
pub struct ClientboundPlayerPositionPacket {
|
||||||
pub x: f64,
|
pub x: f64,
|
||||||
pub y: f64,
|
pub y: f64,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
||||||
use azalea_core::ResourceLocation;
|
use azalea_core::ResourceLocation;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundRecipePacket {
|
pub struct ClientboundRecipePacket {
|
||||||
pub action: State,
|
pub action: State,
|
||||||
pub settings: RecipeBookSettings,
|
pub settings: RecipeBookSettings,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundRemoveEntitiesPacket {
|
pub struct ClientboundRemoveEntitiesPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_ids: Vec<u32>,
|
pub entity_ids: Vec<u32>,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundRotateHeadPacket {
|
pub struct ClientboundRotateHeadPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: u32,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
|
use azalea_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
|
||||||
use azalea_core::{ChunkSectionBlockPos, ChunkSectionPos};
|
use azalea_core::{ChunkSectionBlockPos, ChunkSectionPos};
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSectionBlocksUpdatePacket {
|
pub struct ClientboundSectionBlocksUpdatePacket {
|
||||||
pub section_pos: ChunkSectionPos,
|
pub section_pos: ChunkSectionPos,
|
||||||
pub suppress_light_updates: bool,
|
pub suppress_light_updates: bool,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::component::Component;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundServerDataPacket {
|
pub struct ClientboundServerDataPacket {
|
||||||
pub motd: Option<Component>,
|
pub motd: Option<Component>,
|
||||||
pub icon_base64: Option<String>,
|
pub icon_base64: Option<String>,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
/// Sent to change the player's slot selection.
|
/// Sent to change the player's slot selection.
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetCarriedItemPacket {
|
pub struct ClientboundSetCarriedItemPacket {
|
||||||
pub slot: u8,
|
pub slot: u8,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetChunkCacheCenterPacket {
|
pub struct ClientboundSetChunkCacheCenterPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub x: i32,
|
pub x: i32,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::BlockPos;
|
use azalea_core::BlockPos;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetDefaultSpawnPositionPacket {
|
pub struct ClientboundSetDefaultSpawnPositionPacket {
|
||||||
pub pos: BlockPos,
|
pub pos: BlockPos,
|
||||||
pub angle: f32,
|
pub angle: f32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetDisplayChatPreviewPacket {
|
pub struct ClientboundSetDisplayChatPreviewPacket {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_entity::EntityMetadata;
|
use azalea_entity::EntityMetadata;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetEntityDataPacket {
|
pub struct ClientboundSetEntityDataPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetEntityLinkPacket {
|
pub struct ClientboundSetEntityLinkPacket {
|
||||||
pub source_id: u32,
|
pub source_id: u32,
|
||||||
pub dest_id: u32,
|
pub dest_id: u32,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::Slot;
|
use azalea_core::Slot;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
use azalea_buf::{McBufReadable, McBufWritable};
|
use azalea_buf::{McBufReadable, McBufWritable};
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetEquipmentPacket {
|
pub struct ClientboundSetEquipmentPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity: i32,
|
pub entity: i32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetExperiencePacket {
|
pub struct ClientboundSetExperiencePacket {
|
||||||
pub experience_progress: f32,
|
pub experience_progress: f32,
|
||||||
#[var]
|
#[var]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetHealthPacket {
|
pub struct ClientboundSetHealthPacket {
|
||||||
pub health: f32,
|
pub health: f32,
|
||||||
#[var]
|
#[var]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetTimePacket {
|
pub struct ClientboundSetTimePacket {
|
||||||
pub game_time: u64,
|
pub game_time: u64,
|
||||||
pub day_time: u64,
|
pub day_time: u64,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSoundPacket {
|
pub struct ClientboundSoundPacket {
|
||||||
#[var]
|
#[var]
|
||||||
// TODO: use the sound registry instead of just being a u32
|
// TODO: use the sound registry instead of just being a u32
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::component::Component;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSystemChatPacket {
|
pub struct ClientboundSystemChatPacket {
|
||||||
pub content: Component,
|
pub content: Component,
|
||||||
pub overlay: bool,
|
pub overlay: bool,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundTeleportEntityPacket {
|
pub struct ClientboundTeleportEntityPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
|
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::component::Component;
|
||||||
use azalea_core::{ResourceLocation, Slot};
|
use azalea_core::{ResourceLocation, Slot};
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundUpdateAdvancementsPacket {
|
pub struct ClientboundUpdateAdvancementsPacket {
|
||||||
pub reset: bool,
|
pub reset: bool,
|
||||||
pub added: HashMap<ResourceLocation, Advancement>,
|
pub added: HashMap<ResourceLocation, Advancement>,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
||||||
use azalea_core::ResourceLocation;
|
use azalea_core::ResourceLocation;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundUpdateAttributesPacket {
|
pub struct ClientboundUpdateAttributesPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: u32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundUpdateMobEffectPacket {
|
pub struct ClientboundUpdateMobEffectPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: u32,
|
||||||
|
|
|
@ -2,11 +2,11 @@ use std::io::{Read, Write};
|
||||||
|
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::{ResourceLocation, Slot};
|
use azalea_core::{ResourceLocation, Slot};
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundUpdateRecipesPacket {
|
pub struct ClientboundUpdateRecipesPacket {
|
||||||
pub recipes: Vec<Recipe>,
|
pub recipes: Vec<Recipe>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
|
||||||
use azalea_core::ResourceLocation;
|
use azalea_core::ResourceLocation;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundUpdateTagsPacket {
|
pub struct ClientboundUpdateTagsPacket {
|
||||||
pub tags: TagMap,
|
pub tags: TagMap,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundUpdateViewDistancePacket {
|
pub struct ClientboundUpdateViewDistancePacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub view_distance: i32,
|
pub view_distance: i32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundAcceptTeleportationPacket {
|
pub struct ServerboundAcceptTeleportationPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::packets::game::clientbound_player_chat_packet::LastSeenMessagesUpdate;
|
use crate::packets::game::clientbound_player_chat_packet::LastSeenMessagesUpdate;
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundChatAckPacket {
|
pub struct ServerboundChatAckPacket {
|
||||||
pub last_seen_messages: LastSeenMessagesUpdate,
|
pub last_seen_messages: LastSeenMessagesUpdate,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_crypto::MessageSignature;
|
use azalea_crypto::MessageSignature;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
use super::clientbound_player_chat_packet::LastSeenMessagesUpdate;
|
use super::clientbound_player_chat_packet::LastSeenMessagesUpdate;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundChatCommandPacket {
|
pub struct ServerboundChatCommandPacket {
|
||||||
pub command: String,
|
pub command: String,
|
||||||
// TODO: Choose a real timestamp type
|
// TODO: Choose a real timestamp type
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::packets::game::clientbound_player_chat_packet::LastSeenMessagesUpdate;
|
use crate::packets::game::clientbound_player_chat_packet::LastSeenMessagesUpdate;
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_crypto::MessageSignature;
|
use azalea_crypto::MessageSignature;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundChatPacket {
|
pub struct ServerboundChatPacket {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub timestamp: u64,
|
pub timestamp: u64,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundChatPreviewPacket {
|
pub struct ServerboundChatPreviewPacket {
|
||||||
pub query_id: i32,
|
pub query_id: i32,
|
||||||
pub query: String,
|
pub query: String,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_buf::UnsizedByteArray;
|
use azalea_buf::UnsizedByteArray;
|
||||||
use azalea_core::ResourceLocation;
|
use azalea_core::ResourceLocation;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundCustomPayloadPacket {
|
pub struct ServerboundCustomPayloadPacket {
|
||||||
pub identifier: ResourceLocation,
|
pub identifier: ResourceLocation,
|
||||||
pub data: UnsizedByteArray,
|
pub data: UnsizedByteArray,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundKeepAlivePacket {
|
pub struct ServerboundKeepAlivePacket {
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundMovePlayerPacketPos {
|
pub struct ServerboundMovePlayerPacketPos {
|
||||||
pub x: f64,
|
pub x: f64,
|
||||||
pub y: f64,
|
pub y: f64,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundMovePlayerPacketPosRot {
|
pub struct ServerboundMovePlayerPacketPosRot {
|
||||||
pub x: f64,
|
pub x: f64,
|
||||||
pub y: f64,
|
pub y: f64,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundMovePlayerPacketRot {
|
pub struct ServerboundMovePlayerPacketRot {
|
||||||
pub y_rot: f32,
|
pub y_rot: f32,
|
||||||
pub x_rot: f32,
|
pub x_rot: f32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, GamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundMovePlayerPacketStatusOnly {
|
pub struct ServerboundMovePlayerPacketStatusOnly {
|
||||||
pub on_ground: bool,
|
pub on_ground: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::packets::ConnectionProtocol;
|
use crate::packets::ConnectionProtocol;
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::HandshakePacket;
|
use packet_macros::ClientboundHandshakePacket;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
#[derive(Hash, Clone, Debug, McBuf, HandshakePacket)]
|
#[derive(Hash, Clone, Debug, McBuf, ClientboundHandshakePacket)]
|
||||||
pub struct ClientIntentionPacket {
|
pub struct ClientIntentionPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub protocol_version: u32,
|
pub protocol_version: u32,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use azalea_buf::{McBuf, UnsizedByteArray};
|
use azalea_buf::{McBuf, UnsizedByteArray};
|
||||||
use azalea_core::ResourceLocation;
|
use azalea_core::ResourceLocation;
|
||||||
use packet_macros::LoginPacket;
|
use packet_macros::ClientboundLoginPacket;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
#[derive(Hash, Clone, Debug, McBuf, LoginPacket)]
|
#[derive(Hash, Clone, Debug, McBuf, ClientboundLoginPacket)]
|
||||||
pub struct ClientboundCustomQueryPacket {
|
pub struct ClientboundCustomQueryPacket {
|
||||||
#[var]
|
#[var]
|
||||||
pub transaction_id: u32,
|
pub transaction_id: u32,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
use super::LoginPacket;
|
use super::ClientboundLoginPacket;
|
||||||
use azalea_auth::game_profile::GameProfile;
|
use azalea_auth::game_profile::GameProfile;
|
||||||
use azalea_buf::{McBufReadable, Readable, SerializableUuid, Writable};
|
use azalea_buf::{McBufReadable, Readable, SerializableUuid, Writable};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -12,8 +12,8 @@ pub struct ClientboundGameProfilePacket {
|
||||||
|
|
||||||
// TODO: add derives to GameProfile and have an impl McBufReadable/Writable for GameProfile
|
// TODO: add derives to GameProfile and have an impl McBufReadable/Writable for GameProfile
|
||||||
impl ClientboundGameProfilePacket {
|
impl ClientboundGameProfilePacket {
|
||||||
pub fn get(self) -> LoginPacket {
|
pub fn get(self) -> ClientboundLoginPacket {
|
||||||
LoginPacket::ClientboundGameProfilePacket(self)
|
ClientboundLoginPacket::ClientboundGameProfilePacket(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
|
pub fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
|
||||||
|
@ -24,7 +24,7 @@ impl ClientboundGameProfilePacket {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> {
|
pub fn read(buf: &mut impl Read) -> Result<ClientboundLoginPacket, String> {
|
||||||
let uuid = Uuid::read_from(buf)?;
|
let uuid = Uuid::read_from(buf)?;
|
||||||
let name = buf.read_utf_with_len(16)?;
|
let name = buf.read_utf_with_len(16)?;
|
||||||
Ok(ClientboundGameProfilePacket {
|
Ok(ClientboundGameProfilePacket {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::LoginPacket;
|
use packet_macros::ClientboundLoginPacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, LoginPacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundLoginPacket)]
|
||||||
pub struct ClientboundHelloPacket {
|
pub struct ClientboundHelloPacket {
|
||||||
// TODO: make this len thing work
|
// TODO: make this len thing work
|
||||||
// #[len(20)]
|
// #[len(20)]
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
||||||
|
|
||||||
use azalea_buf::{Readable, Writable};
|
use azalea_buf::{Readable, Writable};
|
||||||
|
|
||||||
use super::LoginPacket;
|
use super::ClientboundLoginPacket;
|
||||||
|
|
||||||
#[derive(Hash, Clone, Debug)]
|
#[derive(Hash, Clone, Debug)]
|
||||||
pub struct ClientboundLoginCompressionPacket {
|
pub struct ClientboundLoginCompressionPacket {
|
||||||
|
@ -13,8 +13,8 @@ pub struct ClientboundLoginCompressionPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientboundLoginCompressionPacket {
|
impl ClientboundLoginCompressionPacket {
|
||||||
pub fn get(self) -> LoginPacket {
|
pub fn get(self) -> ClientboundLoginPacket {
|
||||||
LoginPacket::ClientboundLoginCompressionPacket(self)
|
ClientboundLoginPacket::ClientboundLoginCompressionPacket(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
|
pub fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
|
||||||
|
@ -22,7 +22,7 @@ impl ClientboundLoginCompressionPacket {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> {
|
pub fn read(buf: &mut impl Read) -> Result<ClientboundLoginPacket, String> {
|
||||||
let compression_threshold = buf.read_varint()?;
|
let compression_threshold = buf.read_varint()?;
|
||||||
|
|
||||||
Ok(ClientboundLoginCompressionPacket {
|
Ok(ClientboundLoginCompressionPacket {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::component::Component;
|
||||||
use packet_macros::LoginPacket;
|
use packet_macros::ClientboundLoginPacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, LoginPacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundLoginPacket)]
|
||||||
pub struct ClientboundLoginDisconnectPacket {
|
pub struct ClientboundLoginDisconnectPacket {
|
||||||
pub reason: Component,
|
pub reason: Component,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::LoginPacket;
|
use packet_macros::ServerboundLoginPacket;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, LoginPacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundLoginPacket)]
|
||||||
pub struct ServerboundHelloPacket {
|
pub struct ServerboundHelloPacket {
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub public_key: Option<ProfilePublicKeyData>,
|
pub public_key: Option<ProfilePublicKeyData>,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_crypto::SaltSignaturePair;
|
use azalea_crypto::SaltSignaturePair;
|
||||||
use packet_macros::LoginPacket;
|
use packet_macros::ServerboundLoginPacket;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
use azalea_buf::{McBufReadable, McBufWritable};
|
use azalea_buf::{McBufReadable, McBufWritable};
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, LoginPacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundLoginPacket)]
|
||||||
pub struct ServerboundKeyPacket {
|
pub struct ServerboundKeyPacket {
|
||||||
pub key_bytes: Vec<u8>,
|
pub key_bytes: Vec<u8>,
|
||||||
pub nonce_or_salt_signature: NonceOrSaltSignature,
|
pub nonce_or_salt_signature: NonceOrSaltSignature,
|
||||||
|
|
|
@ -3,7 +3,6 @@ pub mod handshake;
|
||||||
pub mod login;
|
pub mod login;
|
||||||
pub mod status;
|
pub mod status;
|
||||||
|
|
||||||
use crate::connect::PacketFlow;
|
|
||||||
use azalea_buf::{McBufWritable, Readable, Writable};
|
use azalea_buf::{McBufWritable, Readable, Writable};
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
|
@ -29,14 +28,6 @@ impl ConnectionProtocol {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub enum Packet {
|
|
||||||
Game(Box<game::GamePacket>),
|
|
||||||
Handshake(Box<handshake::HandshakePacket>),
|
|
||||||
Login(Box<login::LoginPacket>),
|
|
||||||
Status(Box<status::StatusPacket>),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An enum of packets for a certain protocol
|
/// An enum of packets for a certain protocol
|
||||||
pub trait ProtocolPacket
|
pub trait ProtocolPacket
|
||||||
where
|
where
|
||||||
|
@ -45,7 +36,7 @@ where
|
||||||
fn id(&self) -> u32;
|
fn id(&self) -> u32;
|
||||||
|
|
||||||
/// Read a packet by its id, ConnectionProtocol, and flow
|
/// Read a packet by its id, ConnectionProtocol, and flow
|
||||||
fn read(id: u32, flow: &PacketFlow, buf: &mut impl Read) -> Result<Self, String>;
|
fn read(id: u32, buf: &mut impl Read) -> Result<Self, String>;
|
||||||
|
|
||||||
fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error>;
|
fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
use std::io::{Read, Write};
|
use super::ClientboundStatusPacket;
|
||||||
|
use azalea_buf::Readable;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::component::Component;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
use std::io::{Read, Write};
|
||||||
use azalea_buf::Readable;
|
|
||||||
|
|
||||||
use super::StatusPacket;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
pub struct Version {
|
pub struct Version {
|
||||||
|
@ -37,15 +34,15 @@ pub struct ClientboundStatusResponsePacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientboundStatusResponsePacket {
|
impl ClientboundStatusResponsePacket {
|
||||||
pub fn get(self) -> StatusPacket {
|
pub fn get(self) -> ClientboundStatusPacket {
|
||||||
StatusPacket::ClientboundStatusResponsePacket(self)
|
ClientboundStatusPacket::ClientboundStatusResponsePacket(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> {
|
pub fn write(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(buf: &mut impl Read) -> Result<StatusPacket, String> {
|
pub fn read(buf: &mut impl Read) -> Result<ClientboundStatusPacket, String> {
|
||||||
let status_string = buf.read_utf()?;
|
let status_string = buf.read_utf()?;
|
||||||
let status_json: Value =
|
let status_json: Value =
|
||||||
serde_json::from_str(status_string.as_str()).expect("Server status isn't valid JSON");
|
serde_json::from_str(status_string.as_str()).expect("Server status isn't valid JSON");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use packet_macros::StatusPacket;
|
use packet_macros::ServerboundStatusPacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, StatusPacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundStatusPacket)]
|
||||||
pub struct ServerboundStatusRequestPacket {}
|
pub struct ServerboundStatusRequestPacket {}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{connect::PacketFlow, packets::ProtocolPacket};
|
use crate::packets::ProtocolPacket;
|
||||||
use azalea_buf::{read_varint_async, Readable};
|
use azalea_buf::{read_varint_async, Readable};
|
||||||
use azalea_crypto::Aes128CfbDec;
|
use azalea_crypto::Aes128CfbDec;
|
||||||
use flate2::read::ZlibDecoder;
|
use flate2::read::ZlibDecoder;
|
||||||
|
@ -31,13 +31,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn packet_decoder<P: ProtocolPacket>(
|
fn packet_decoder<P: ProtocolPacket>(stream: &mut impl Read) -> Result<P, String> {
|
||||||
stream: &mut impl Read,
|
|
||||||
flow: &PacketFlow,
|
|
||||||
) -> Result<P, String> {
|
|
||||||
// Packet ID
|
// Packet ID
|
||||||
let packet_id = stream.read_varint()?;
|
let packet_id = stream.read_varint()?;
|
||||||
P::read(packet_id.try_into().unwrap(), flow, stream)
|
P::read(packet_id.try_into().unwrap(), stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is always true in multiplayer, false in singleplayer
|
// this is always true in multiplayer, false in singleplayer
|
||||||
|
@ -121,7 +118,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn read_packet<'a, P: ProtocolPacket, R>(
|
pub async fn read_packet<'a, P: ProtocolPacket, R>(
|
||||||
flow: &PacketFlow,
|
|
||||||
stream: &'a mut R,
|
stream: &'a mut R,
|
||||||
compression_threshold: Option<u32>,
|
compression_threshold: Option<u32>,
|
||||||
cipher: &mut Option<Aes128CfbDec>,
|
cipher: &mut Option<Aes128CfbDec>,
|
||||||
|
@ -150,7 +146,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// println!("decoding packet ({}ms)", start_time.elapsed().as_millis());
|
// println!("decoding packet ({}ms)", start_time.elapsed().as_millis());
|
||||||
let packet = packet_decoder(&mut buf.as_slice(), flow)?;
|
let packet = packet_decoder(&mut buf.as_slice())?;
|
||||||
// println!("decoded packet ({}ms)", start_time.elapsed().as_millis());
|
// println!("decoded packet ({}ms)", start_time.elapsed().as_millis());
|
||||||
|
|
||||||
Ok(packet)
|
Ok(packet)
|
||||||
|
|
Loading…
Add table
Reference in a new issue