add clientbound packet: CCloseContainer
This commit is contained in:
parent
f9134b580d
commit
7c2b650bdb
16
pumpkin-protocol/src/client/play/c_close_container.rs
Normal file
16
pumpkin-protocol/src/client/play/c_close_container.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use serde::Serialize;
|
||||
use pumpkin_macros::packet;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[packet(0x12)]
|
||||
pub struct CCloseContainer {
|
||||
window_id: u8
|
||||
}
|
||||
|
||||
impl CCloseContainer {
|
||||
pub const fn new(window_id: u8) -> Self {
|
||||
Self {
|
||||
window_id
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -36,6 +36,7 @@ mod c_update_entity_pos;
|
||||
mod c_update_entity_rot;
|
||||
mod c_worldevent;
|
||||
mod player_action;
|
||||
mod c_close_container;
|
||||
|
||||
pub use c_acknowledge_block::*;
|
||||
pub use c_actionbar::*;
|
||||
@ -75,3 +76,4 @@ pub use c_update_entity_pos::*;
|
||||
pub use c_update_entity_rot::*;
|
||||
pub use c_worldevent::*;
|
||||
pub use player_action::*;
|
||||
pub use c_close_container::*;
|
||||
@ -1,6 +1,6 @@
|
||||
use pumpkin_core::text::TextComponent;
|
||||
use pumpkin_inventory::WindowType;
|
||||
use pumpkin_protocol::client::play::{COpenScreen, CSetContainerContent, CSetContainerSlot};
|
||||
use pumpkin_protocol::client::play::{CCloseContainer, COpenScreen, CSetContainerContent, CSetContainerSlot};
|
||||
use pumpkin_protocol::slot::Slot;
|
||||
use pumpkin_world::item::Item;
|
||||
|
||||
@ -82,4 +82,12 @@ impl super::Client {
|
||||
&item.into(),
|
||||
))
|
||||
}
|
||||
|
||||
/// The official Minecraft client is weird, and will always just close *any* window that is opened when this gets sent
|
||||
pub fn close_container(
|
||||
&mut self,
|
||||
window_type: WindowType
|
||||
) {
|
||||
self.send_packet(&CCloseContainer::new(window_type as u8))
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user