make packet public and more abstraction thing

This commit is contained in:
Edvin Bryntesson 2024-08-25 11:47:53 +02:00
parent c408244b37
commit c968131e04
No known key found for this signature in database
4 changed files with 28 additions and 15 deletions

View File

@ -1,8 +1,17 @@
#![allow(dead_code, unused)] use crate::WindowType;
use pumpkin_world::item::Item;
pub struct ClickMode { pub struct ClickMode {
slot: Slot, pub slot: Slot,
click_type: ClickType, pub click_type: ClickType,
}
pub struct Click {
pub mode: ClickMode,
pub state_id: u32,
pub window_type: WindowType,
pub changed_items: Vec<(usize, Item)>,
pub carried_item: Option<Item>,
} }
impl ClickMode { impl ClickMode {
@ -37,13 +46,13 @@ impl ClickMode {
} }
}; };
let button = match button { let button = match button {
0 => Click::Left, 0 => MouseClick::Left,
1 => Click::Right, 1 => MouseClick::Right,
// TODO: Error here // TODO: Error here
_ => unreachable!(), _ => unreachable!(),
}; };
Self { Self {
click_type: ClickType::NormalClick(button), click_type: ClickType::MouseClick(button),
slot, slot,
} }
} }
@ -146,8 +155,8 @@ impl ClickMode {
} }
} }
enum ClickType { pub enum ClickType {
NormalClick(Click), MouseClick(MouseClick),
ShiftClick, ShiftClick,
KeyClick(KeyClick), KeyClick(KeyClick),
CreativePickItem, CreativePickItem,
@ -158,34 +167,34 @@ enum ClickType {
}, },
DoubleClick, DoubleClick,
} }
enum Click { pub enum MouseClick {
Left, Left,
Right, Right,
Middle, Middle,
} }
enum KeyClick { pub enum KeyClick {
Slot(u8), Slot(u8),
Offhand, Offhand,
} }
enum Slot { pub enum Slot {
Normal(usize), Normal(usize),
OutsideInventory, OutsideInventory,
} }
enum DropType { pub enum DropType {
SingleItem, SingleItem,
FullStack, FullStack,
} }
enum MouseDragType { pub enum MouseDragType {
Left, Left,
Right, Right,
Middle, Middle,
} }
enum MouseDragState { pub enum MouseDragState {
Start, Start,
AddSlot, AddSlot,
End, End,

View File

@ -1,6 +1,6 @@
use num_derive::{FromPrimitive, ToPrimitive}; use num_derive::{FromPrimitive, ToPrimitive};
mod container_click; pub mod container_click;
pub mod player; pub mod player;
pub mod window_property; pub mod window_property;

View File

@ -18,6 +18,7 @@ mod s_use_item_on;
pub use s_chat_command::*; pub use s_chat_command::*;
pub use s_chat_message::*; pub use s_chat_message::*;
pub use s_click_container::*;
pub use s_client_information::*; pub use s_client_information::*;
pub use s_close_container::*; pub use s_close_container::*;
pub use s_confirm_teleport::*; pub use s_confirm_teleport::*;

View File

@ -1,9 +1,12 @@
use pumpkin_core::text::TextComponent; use pumpkin_core::text::TextComponent;
use pumpkin_inventory::container_click;
use pumpkin_inventory::container_click::KeyClick;
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::{ use pumpkin_protocol::client::play::{
CCloseContainer, COpenScreen, CSetContainerContent, CSetContainerProperty, CSetContainerSlot, CCloseContainer, COpenScreen, CSetContainerContent, CSetContainerProperty, CSetContainerSlot,
}; };
use pumpkin_protocol::server::play::SClickContainer;
use pumpkin_protocol::slot::Slot; use pumpkin_protocol::slot::Slot;
use pumpkin_world::item::Item; use pumpkin_world::item::Item;