diff --git a/pumpkin-inventory/src/window_property.rs b/pumpkin-inventory/src/window_property.rs index 64e24d044..67deb646e 100644 --- a/pumpkin-inventory/src/window_property.rs +++ b/pumpkin-inventory/src/window_property.rs @@ -6,28 +6,27 @@ pub trait WindowPropertyTrait: Sized { pub struct WindowProperty { window_property: T, - value: i16 + value: i16, } impl WindowProperty { - pub fn new(window_property: T,value: i16) -> Self { + pub fn new(window_property: T, value: i16) -> Self { Self { window_property, - value + value, } } - - pub fn into_packet(self) -> (i16,i16) { + + pub fn into_packet(self) -> (i16, i16) { (self.window_property.to_id(), self.value) } } - pub enum Furnace { FireIcon, MaximumFuelBurnTime, ProgressArrow, - MaximumProgress + MaximumProgress, } impl WindowPropertyTrait for Furnace { @@ -36,17 +35,11 @@ impl WindowPropertyTrait for Furnace { } } - - pub enum EnchantmentTable { - LevelRequirement{ - slot:u8 - }, + LevelRequirement { slot: u8 }, EnchantmentSeed, - EnchantmentId{ - slot:u8 - }, - EnchantmentLevel{slot:u8}, + EnchantmentId { slot: u8 }, + EnchantmentLevel { slot: u8 }, } impl WindowPropertyTrait for EnchantmentTable { @@ -54,10 +47,10 @@ impl WindowPropertyTrait for EnchantmentTable { use EnchantmentTable::*; (match self { - LevelRequirement{slot} => slot, + LevelRequirement { slot } => slot, EnchantmentSeed => 3, - EnchantmentId{slot} => 4+slot, - EnchantmentLevel{slot} => 7+slot, + EnchantmentId { slot } => 4 + slot, + EnchantmentLevel { slot } => 7 + slot, }) as i16 } } @@ -65,7 +58,7 @@ impl WindowPropertyTrait for EnchantmentTable { pub enum Beacon { PowerLevel, FirstPotionEffect, - SecondPotionEffect + SecondPotionEffect, } impl WindowPropertyTrait for Beacon { @@ -75,14 +68,14 @@ impl WindowPropertyTrait for Beacon { } pub enum Anvil { - RepairCost + RepairCost, } impl WindowPropertyTrait for Anvil {} -pub enum BrewingStand{ +pub enum BrewingStand { BrewTime, - FuelTime + FuelTime, } impl WindowPropertyTrait for BrewingStand { @@ -92,20 +85,19 @@ impl WindowPropertyTrait for BrewingStand { } pub enum Stonecutter { - SelectedRecipe + SelectedRecipe, } impl WindowPropertyTrait for Stonecutter {} pub enum Loom { - SelectedPattern + SelectedPattern, } impl WindowPropertyTrait for Loom {} pub enum Lectern { - PageNumber + PageNumber, } impl WindowPropertyTrait for Lectern {} - diff --git a/pumpkin-protocol/src/client/play/c_close_container.rs b/pumpkin-protocol/src/client/play/c_close_container.rs index 56c3bb457..b8350265b 100644 --- a/pumpkin-protocol/src/client/play/c_close_container.rs +++ b/pumpkin-protocol/src/client/play/c_close_container.rs @@ -1,16 +1,14 @@ -use serde::Serialize; use pumpkin_macros::packet; +use serde::Serialize; #[derive(Serialize)] #[packet(0x12)] pub struct CCloseContainer { - window_id: u8 + window_id: u8, } impl CCloseContainer { pub const fn new(window_id: u8) -> Self { - Self { - window_id - } + Self { window_id } } -} \ No newline at end of file +} diff --git a/pumpkin-protocol/src/client/play/c_set_container_property.rs b/pumpkin-protocol/src/client/play/c_set_container_property.rs index fd54753fe..1fee26ef5 100644 --- a/pumpkin-protocol/src/client/play/c_set_container_property.rs +++ b/pumpkin-protocol/src/client/play/c_set_container_property.rs @@ -1,19 +1,19 @@ -use serde::Serialize; use pumpkin_macros::packet; +use serde::Serialize; #[derive(Serialize)] #[packet(0x14)] pub struct CSetContainerProperty { window_id: u8, property: i16, - value: i16 + value: i16, } impl CSetContainerProperty { - pub const fn new(window_id: u8, property: i16, value:i16) -> Self { + pub const fn new(window_id: u8, property: i16, value: i16) -> Self { Self { window_id, property, - value + value, } } } diff --git a/pumpkin-protocol/src/client/play/mod.rs b/pumpkin-protocol/src/client/play/mod.rs index 838c79272..8d4a6e84b 100644 --- a/pumpkin-protocol/src/client/play/mod.rs +++ b/pumpkin-protocol/src/client/play/mod.rs @@ -5,6 +5,7 @@ mod c_block_update; mod c_center_chunk; mod c_change_difficulty; mod c_chunk_data; +mod c_close_container; mod c_disguised_chat_message; mod c_entity_animation; mod c_entity_metadata; @@ -23,6 +24,7 @@ mod c_player_info_update; mod c_player_remove; mod c_remove_entities; mod c_set_container_content; +mod c_set_container_property; mod c_set_container_slot; mod c_set_held_item; mod c_set_title; @@ -36,8 +38,6 @@ mod c_update_entity_pos; mod c_update_entity_rot; mod c_worldevent; mod player_action; -mod c_close_container; -mod c_set_container_property; pub use c_acknowledge_block::*; pub use c_actionbar::*; @@ -46,6 +46,7 @@ pub use c_block_update::*; pub use c_center_chunk::*; pub use c_change_difficulty::*; pub use c_chunk_data::*; +pub use c_close_container::*; pub use c_disguised_chat_message::*; pub use c_entity_animation::*; pub use c_entity_metadata::*; @@ -64,6 +65,7 @@ pub use c_player_info_update::*; pub use c_player_remove::*; pub use c_remove_entities::*; pub use c_set_container_content::*; +pub use c_set_container_property::*; pub use c_set_container_slot::*; pub use c_set_held_item::*; pub use c_set_title::*; @@ -77,5 +79,3 @@ 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::*; -pub use c_set_container_property::*; \ No newline at end of file diff --git a/pumpkin/src/client/container.rs b/pumpkin/src/client/container.rs index edec9f39e..a0c852b53 100644 --- a/pumpkin/src/client/container.rs +++ b/pumpkin/src/client/container.rs @@ -1,7 +1,9 @@ use pumpkin_core::text::TextComponent; use pumpkin_inventory::window_property::{WindowProperty, WindowPropertyTrait}; use pumpkin_inventory::WindowType; -use pumpkin_protocol::client::play::{CCloseContainer, COpenScreen, CSetContainerContent, CSetContainerProperty, CSetContainerSlot}; +use pumpkin_protocol::client::play::{ + CCloseContainer, COpenScreen, CSetContainerContent, CSetContainerProperty, CSetContainerSlot, +}; use pumpkin_protocol::slot::Slot; use pumpkin_world::item::Item; @@ -83,17 +85,18 @@ 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 - ) { + + /// 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)) } - - pub fn set_container_property(&mut self, window_type: WindowType, window_property: WindowProperty) { - let (id,value) = window_property.into_packet(); - self.send_packet(&CSetContainerProperty::new(window_type as u8,id,value)); + + pub fn set_container_property( + &mut self, + window_type: WindowType, + window_property: WindowProperty, + ) { + let (id, value) = window_property.into_packet(); + self.send_packet(&CSetContainerProperty::new(window_type as u8, id, value)); } }