add serverbound packet SContainerClose

This commit is contained in:
Edvin Bryntesson 2024-08-23 11:51:37 +02:00
parent e1a7d4e7ee
commit ef21b3ae40
No known key found for this signature in database
3 changed files with 8 additions and 5 deletions

View File

@ -1,7 +1,7 @@
use pumpkin_macros::packet;
use serde::Serialize;
use serde::Deserialize;
#[derive(Serialize)]
#[derive(Deserialize)]
#[packet(0x0F)]
pub struct SCloseContainer {
pub window_id: u8,

View File

@ -28,8 +28,8 @@ use pumpkin_protocol::{
handshake::SHandShake,
login::{SEncryptionResponse, SLoginAcknowledged, SLoginPluginResponse, SLoginStart},
play::{
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
SPlayPingRequest, SPlayerAction, SPlayerCommand, SPlayerPosition,
SChatCommand, SChatMessage, SClientInformationPlay, SCloseContainer, SConfirmTeleport,
SInteract, SPlayPingRequest, SPlayerAction, SPlayerCommand, SPlayerPosition,
SPlayerPositionRotation, SPlayerRotation, SSetCreativeSlot, SSetHeldItem, SSwingArm,
SUseItemOn,
},
@ -312,6 +312,9 @@ impl Client {
SPlayPingRequest::PACKET_ID => {
self.handle_play_ping_request(server, SPlayPingRequest::read(bytebuf).unwrap())
}
SCloseContainer::PACKET_ID => {
self.handle_close_container(server, SCloseContainer::read(bytebuf).unwrap())
}
_ => log::error!("Failed to handle player packet id {:#04x}", packet.id.0),
}
}

View File

@ -420,7 +420,7 @@ impl Client {
// TODO:
// This function will in the future be used to keep track of if the client is in a valid state.
// But this is not possible yet
pub fn handle_close_container(&mut self, packet: SCloseContainer) {
pub fn handle_close_container(&mut self, _server: &mut Server, packet: SCloseContainer) {
// window_id 0 represents both 9x1 Generic AND inventory here
let Ok(_window_type) = WindowType::try_from(packet.window_id) else {
self.kick("Invalid window ID");