add method to set container property

This commit is contained in:
Edvin Bryntesson
2024-08-23 11:51:51 +02:00
parent 1d1dcc6a85
commit 4523900de4

View File

@@ -1,6 +1,7 @@
use pumpkin_core::text::TextComponent;
use pumpkin_inventory::window_property::{WindowProperty, WindowPropertyTrait};
use pumpkin_inventory::WindowType;
use pumpkin_protocol::client::play::{CCloseContainer, COpenScreen, CSetContainerContent, CSetContainerSlot};
use pumpkin_protocol::client::play::{CCloseContainer, COpenScreen, CSetContainerContent, CSetContainerProperty, CSetContainerSlot};
use pumpkin_protocol::slot::Slot;
use pumpkin_world::item::Item;
@@ -90,4 +91,9 @@ impl super::Client {
) {
self.send_packet(&CCloseContainer::new(window_type as u8))
}
pub fn set_container_property<T: WindowPropertyTrait>(&mut self, window_type: WindowType, window_property: WindowProperty<T>) {
let (id,value) = window_property.into_packet();
self.send_packet(&CSetContainerProperty::new(window_type as u8,id,value));
}
}