formatting
This commit is contained in:
parent
4523900de4
commit
98fcd412c2
@ -6,28 +6,27 @@ pub trait WindowPropertyTrait: Sized {
|
|||||||
|
|
||||||
pub struct WindowProperty<T: WindowPropertyTrait> {
|
pub struct WindowProperty<T: WindowPropertyTrait> {
|
||||||
window_property: T,
|
window_property: T,
|
||||||
value: i16
|
value: i16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: WindowPropertyTrait> WindowProperty<T> {
|
impl<T: WindowPropertyTrait> WindowProperty<T> {
|
||||||
pub fn new(window_property: T,value: i16) -> Self {
|
pub fn new(window_property: T, value: i16) -> Self {
|
||||||
Self {
|
Self {
|
||||||
window_property,
|
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)
|
(self.window_property.to_id(), self.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub enum Furnace {
|
pub enum Furnace {
|
||||||
FireIcon,
|
FireIcon,
|
||||||
MaximumFuelBurnTime,
|
MaximumFuelBurnTime,
|
||||||
ProgressArrow,
|
ProgressArrow,
|
||||||
MaximumProgress
|
MaximumProgress,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowPropertyTrait for Furnace {
|
impl WindowPropertyTrait for Furnace {
|
||||||
@ -36,17 +35,11 @@ impl WindowPropertyTrait for Furnace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub enum EnchantmentTable {
|
pub enum EnchantmentTable {
|
||||||
LevelRequirement{
|
LevelRequirement { slot: u8 },
|
||||||
slot:u8
|
|
||||||
},
|
|
||||||
EnchantmentSeed,
|
EnchantmentSeed,
|
||||||
EnchantmentId{
|
EnchantmentId { slot: u8 },
|
||||||
slot:u8
|
EnchantmentLevel { slot: u8 },
|
||||||
},
|
|
||||||
EnchantmentLevel{slot:u8},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowPropertyTrait for EnchantmentTable {
|
impl WindowPropertyTrait for EnchantmentTable {
|
||||||
@ -54,10 +47,10 @@ impl WindowPropertyTrait for EnchantmentTable {
|
|||||||
use EnchantmentTable::*;
|
use EnchantmentTable::*;
|
||||||
|
|
||||||
(match self {
|
(match self {
|
||||||
LevelRequirement{slot} => slot,
|
LevelRequirement { slot } => slot,
|
||||||
EnchantmentSeed => 3,
|
EnchantmentSeed => 3,
|
||||||
EnchantmentId{slot} => 4+slot,
|
EnchantmentId { slot } => 4 + slot,
|
||||||
EnchantmentLevel{slot} => 7+slot,
|
EnchantmentLevel { slot } => 7 + slot,
|
||||||
}) as i16
|
}) as i16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,7 +58,7 @@ impl WindowPropertyTrait for EnchantmentTable {
|
|||||||
pub enum Beacon {
|
pub enum Beacon {
|
||||||
PowerLevel,
|
PowerLevel,
|
||||||
FirstPotionEffect,
|
FirstPotionEffect,
|
||||||
SecondPotionEffect
|
SecondPotionEffect,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowPropertyTrait for Beacon {
|
impl WindowPropertyTrait for Beacon {
|
||||||
@ -75,14 +68,14 @@ impl WindowPropertyTrait for Beacon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum Anvil {
|
pub enum Anvil {
|
||||||
RepairCost
|
RepairCost,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowPropertyTrait for Anvil {}
|
impl WindowPropertyTrait for Anvil {}
|
||||||
|
|
||||||
pub enum BrewingStand{
|
pub enum BrewingStand {
|
||||||
BrewTime,
|
BrewTime,
|
||||||
FuelTime
|
FuelTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowPropertyTrait for BrewingStand {
|
impl WindowPropertyTrait for BrewingStand {
|
||||||
@ -92,20 +85,19 @@ impl WindowPropertyTrait for BrewingStand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum Stonecutter {
|
pub enum Stonecutter {
|
||||||
SelectedRecipe
|
SelectedRecipe,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowPropertyTrait for Stonecutter {}
|
impl WindowPropertyTrait for Stonecutter {}
|
||||||
|
|
||||||
pub enum Loom {
|
pub enum Loom {
|
||||||
SelectedPattern
|
SelectedPattern,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowPropertyTrait for Loom {}
|
impl WindowPropertyTrait for Loom {}
|
||||||
|
|
||||||
pub enum Lectern {
|
pub enum Lectern {
|
||||||
PageNumber
|
PageNumber,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowPropertyTrait for Lectern {}
|
impl WindowPropertyTrait for Lectern {}
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,14 @@
|
|||||||
use serde::Serialize;
|
|
||||||
use pumpkin_macros::packet;
|
use pumpkin_macros::packet;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[packet(0x12)]
|
#[packet(0x12)]
|
||||||
pub struct CCloseContainer {
|
pub struct CCloseContainer {
|
||||||
window_id: u8
|
window_id: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CCloseContainer {
|
impl CCloseContainer {
|
||||||
pub const fn new(window_id: u8) -> Self {
|
pub const fn new(window_id: u8) -> Self {
|
||||||
Self {
|
Self { window_id }
|
||||||
window_id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
use serde::Serialize;
|
|
||||||
use pumpkin_macros::packet;
|
use pumpkin_macros::packet;
|
||||||
|
use serde::Serialize;
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[packet(0x14)]
|
#[packet(0x14)]
|
||||||
pub struct CSetContainerProperty {
|
pub struct CSetContainerProperty {
|
||||||
window_id: u8,
|
window_id: u8,
|
||||||
property: i16,
|
property: i16,
|
||||||
value: i16
|
value: i16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSetContainerProperty {
|
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 {
|
Self {
|
||||||
window_id,
|
window_id,
|
||||||
property,
|
property,
|
||||||
value
|
value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ mod c_block_update;
|
|||||||
mod c_center_chunk;
|
mod c_center_chunk;
|
||||||
mod c_change_difficulty;
|
mod c_change_difficulty;
|
||||||
mod c_chunk_data;
|
mod c_chunk_data;
|
||||||
|
mod c_close_container;
|
||||||
mod c_disguised_chat_message;
|
mod c_disguised_chat_message;
|
||||||
mod c_entity_animation;
|
mod c_entity_animation;
|
||||||
mod c_entity_metadata;
|
mod c_entity_metadata;
|
||||||
@ -23,6 +24,7 @@ mod c_player_info_update;
|
|||||||
mod c_player_remove;
|
mod c_player_remove;
|
||||||
mod c_remove_entities;
|
mod c_remove_entities;
|
||||||
mod c_set_container_content;
|
mod c_set_container_content;
|
||||||
|
mod c_set_container_property;
|
||||||
mod c_set_container_slot;
|
mod c_set_container_slot;
|
||||||
mod c_set_held_item;
|
mod c_set_held_item;
|
||||||
mod c_set_title;
|
mod c_set_title;
|
||||||
@ -36,8 +38,6 @@ mod c_update_entity_pos;
|
|||||||
mod c_update_entity_rot;
|
mod c_update_entity_rot;
|
||||||
mod c_worldevent;
|
mod c_worldevent;
|
||||||
mod player_action;
|
mod player_action;
|
||||||
mod c_close_container;
|
|
||||||
mod c_set_container_property;
|
|
||||||
|
|
||||||
pub use c_acknowledge_block::*;
|
pub use c_acknowledge_block::*;
|
||||||
pub use c_actionbar::*;
|
pub use c_actionbar::*;
|
||||||
@ -46,6 +46,7 @@ pub use c_block_update::*;
|
|||||||
pub use c_center_chunk::*;
|
pub use c_center_chunk::*;
|
||||||
pub use c_change_difficulty::*;
|
pub use c_change_difficulty::*;
|
||||||
pub use c_chunk_data::*;
|
pub use c_chunk_data::*;
|
||||||
|
pub use c_close_container::*;
|
||||||
pub use c_disguised_chat_message::*;
|
pub use c_disguised_chat_message::*;
|
||||||
pub use c_entity_animation::*;
|
pub use c_entity_animation::*;
|
||||||
pub use c_entity_metadata::*;
|
pub use c_entity_metadata::*;
|
||||||
@ -64,6 +65,7 @@ pub use c_player_info_update::*;
|
|||||||
pub use c_player_remove::*;
|
pub use c_player_remove::*;
|
||||||
pub use c_remove_entities::*;
|
pub use c_remove_entities::*;
|
||||||
pub use c_set_container_content::*;
|
pub use c_set_container_content::*;
|
||||||
|
pub use c_set_container_property::*;
|
||||||
pub use c_set_container_slot::*;
|
pub use c_set_container_slot::*;
|
||||||
pub use c_set_held_item::*;
|
pub use c_set_held_item::*;
|
||||||
pub use c_set_title::*;
|
pub use c_set_title::*;
|
||||||
@ -77,5 +79,3 @@ pub use c_update_entity_pos::*;
|
|||||||
pub use c_update_entity_rot::*;
|
pub use c_update_entity_rot::*;
|
||||||
pub use c_worldevent::*;
|
pub use c_worldevent::*;
|
||||||
pub use player_action::*;
|
pub use player_action::*;
|
||||||
pub use c_close_container::*;
|
|
||||||
pub use c_set_container_property::*;
|
|
||||||
@ -1,7 +1,9 @@
|
|||||||
use pumpkin_core::text::TextComponent;
|
use pumpkin_core::text::TextComponent;
|
||||||
use pumpkin_inventory::window_property::{WindowProperty, WindowPropertyTrait};
|
use pumpkin_inventory::window_property::{WindowProperty, WindowPropertyTrait};
|
||||||
use pumpkin_inventory::WindowType;
|
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_protocol::slot::Slot;
|
||||||
use pumpkin_world::item::Item;
|
use pumpkin_world::item::Item;
|
||||||
|
|
||||||
@ -83,17 +85,18 @@ impl super::Client {
|
|||||||
&item.into(),
|
&item.into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The official Minecraft client is weird, and will always just close *any* window that is opened when this gets sent
|
/// The official Minecraft client is weird, and will always just close *any* window that is opened when this gets sent
|
||||||
pub fn close_container(
|
pub fn close_container(&mut self, window_type: WindowType) {
|
||||||
&mut self,
|
|
||||||
window_type: WindowType
|
|
||||||
) {
|
|
||||||
self.send_packet(&CCloseContainer::new(window_type as u8))
|
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>) {
|
pub fn set_container_property<T: WindowPropertyTrait>(
|
||||||
let (id,value) = window_property.into_packet();
|
&mut self,
|
||||||
self.send_packet(&CSetContainerProperty::new(window_type as u8,id,value));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user