From 188428950722ccaa9b163c12fca92133f18316ba Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 16 Dec 2025 05:41:25 -0500 Subject: implement cookie packets to fix betteranticheat support --- azalea-client/src/plugins/packet/game/mod.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'azalea-client/src/plugins/packet/game') diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index 89b33274..f39a9f8f 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -29,6 +29,7 @@ use crate::{ chat::{ChatPacket, ChatReceivedEvent}, chunks, connection::RawConnection, + cookies::{RequestCookieEvent, StoreCookieEvent}, disconnect::DisconnectEvent, interact::BlockStatePredictionHandler, inventory::{ClientsideCloseContainerEvent, MenuOpenedEvent, SetContainerContentEvent}, @@ -1599,10 +1600,27 @@ impl GamePacketHandler<'_> { pub fn ticking_state(&mut self, _p: &ClientboundTickingState) {} pub fn ticking_step(&mut self, _p: &ClientboundTickingStep) {} pub fn reset_score(&mut self, _p: &ClientboundResetScore) {} - pub fn cookie_request(&mut self, _p: &ClientboundCookieRequest) {} + pub fn cookie_request(&mut self, p: &ClientboundCookieRequest) { + debug!("Got cookie request packet {p:?}"); + as_system::(self.ecs, |mut commands| { + commands.trigger(RequestCookieEvent { + entity: self.player, + key: p.key.clone(), + }); + }); + } + pub fn store_cookie(&mut self, p: &ClientboundStoreCookie) { + debug!("Got store cookie packet {p:?}"); + as_system::(self.ecs, |mut commands| { + commands.trigger(StoreCookieEvent { + entity: self.player, + key: p.key.clone(), + payload: p.payload.clone(), + }); + }); + } pub fn debug_sample(&mut self, _p: &ClientboundDebugSample) {} pub fn pong_response(&mut self, _p: &ClientboundPongResponse) {} - pub fn store_cookie(&mut self, _p: &ClientboundStoreCookie) {} pub fn transfer(&mut self, _p: &ClientboundTransfer) {} pub fn move_minecart_along_track(&mut self, _p: &ClientboundMoveMinecartAlongTrack) {} pub fn set_held_slot(&mut self, p: &ClientboundSetHeldSlot) { -- cgit v1.2.3