1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

add keepalive packets

This commit is contained in:
mat 2022-05-07 20:41:33 -05:00
parent 49454781cf
commit 98eee6d908
4 changed files with 27 additions and 1 deletions

View file

@ -3,7 +3,10 @@ use azalea_core::resource_location::ResourceLocation;
use azalea_protocol::{
connect::{GameConnection, HandshakeConnection},
packets::{
game::{serverbound_custom_payload_packet::ServerboundCustomPayloadPacket, GamePacket},
game::{
serverbound_custom_payload_packet::ServerboundCustomPayloadPacket,
serverbound_keep_alive_packet::ServerboundKeepAlivePacket, GamePacket,
},
handshake::client_intention_packet::ClientIntentionPacket,
login::{
serverbound_hello_packet::ServerboundHelloPacket,
@ -294,6 +297,13 @@ impl Client {
GamePacket::ClientboundMoveEntityRotPacket(p) => {
println!("Got move entity rot packet {:?}", p);
}
GamePacket::ClientboundKeepAlivePacket(p) => {
println!("Got keep alive packet {:?}", p);
conn.lock()
.await
.write(ServerboundKeepAlivePacket { id: p.id }.get())
.await;
}
_ => panic!("Unexpected packet {:?}", packet),
}
println!();

View file

@ -0,0 +1,6 @@
use packet_macros::GamePacket;
#[derive(Clone, Debug, GamePacket)]
pub struct ClientboundKeepAlivePacket {
pub id: u64,
}

View file

@ -9,6 +9,7 @@ pub mod clientbound_disconnect_packet;
pub mod clientbound_entity_event_packet;
pub mod clientbound_entity_velocity_packet;
pub mod clientbound_initialize_border_packet;
pub mod clientbound_keep_alive_packet;
pub mod clientbound_level_chunk_with_light_packet;
pub mod clientbound_light_update_packet;
pub mod clientbound_login_packet;
@ -35,6 +36,7 @@ pub mod clientbound_update_recipes_packet;
pub mod clientbound_update_tags_packet;
pub mod clientbound_update_view_distance_packet;
pub mod serverbound_custom_payload_packet;
pub mod serverbound_keep_alive_packet;
use packet_macros::declare_state_packets;
@ -42,6 +44,7 @@ declare_state_packets!(
GamePacket,
Serverbound => {
0x0a: serverbound_custom_payload_packet::ServerboundCustomPayloadPacket,
0x0f: serverbound_keep_alive_packet::ServerboundKeepAlivePacket,
},
Clientbound => {
0x00: clientbound_add_entity_packet::ClientboundAddEntityPacket,
@ -54,6 +57,7 @@ declare_state_packets!(
0x1b: clientbound_entity_event_packet::ClientboundEntityEventPacket,
0x18: clientbound_custom_payload_packet::ClientboundCustomPayloadPacket,
0x20: clientbound_initialize_border_packet::ClientboundInitializeBorderPacket,
0x21: clientbound_keep_alive_packet::ClientboundKeepAlivePacket,
0x22: clientbound_level_chunk_with_light_packet::ClientboundLevelChunkWithLightPacket,
0x25: clientbound_light_update_packet::ClientboundLightUpdatePacket,
0x26: clientbound_login_packet::ClientboundLoginPacket,

View file

@ -0,0 +1,6 @@
use packet_macros::GamePacket;
#[derive(Clone, Debug, GamePacket)]
pub struct ServerboundKeepAlivePacket {
pub id: u64,
}