diff --git a/src/client.rs b/src/client.rs index e2f7aa7..635bc92 100644 --- a/src/client.rs +++ b/src/client.rs @@ -740,8 +740,8 @@ impl Client { }) } C2sPlayPacket::RequestCommandCompletion(_) => {} - C2sPlayPacket::ButtonClick(_) => {} - C2sPlayPacket::ClickSlot(_) => {} + C2sPlayPacket::ClickContainerButton(_) => {} + C2sPlayPacket::ClickContainer(_) => {} C2sPlayPacket::CloseHandledScreen(_) => {} C2sPlayPacket::CustomPayload(_) => {} C2sPlayPacket::BookUpdate(_) => {} diff --git a/src/protocol.rs b/src/protocol.rs index 7bc57a7..4748035 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -12,6 +12,7 @@ pub use byte_angle::ByteAngle; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use serde::de::DeserializeOwned; use serde::Serialize; +pub use slot::Slot; use uuid::Uuid; pub use var_int::VarInt; pub use var_long::VarLong; @@ -23,7 +24,7 @@ use crate::nbt; mod byte_angle; pub mod codec; pub mod packets; -pub mod slot; +mod slot; mod var_int; mod var_long; diff --git a/src/protocol/packets.rs b/src/protocol/packets.rs index c0f6341..8791f11 100644 --- a/src/protocol/packets.rs +++ b/src/protocol/packets.rs @@ -23,7 +23,7 @@ use crate::block_pos::BlockPos; use crate::ident::Ident; use crate::nbt::Compound; use crate::protocol::{ - BoundedArray, BoundedInt, BoundedString, ByteAngle, Decode, Encode, NbtBridge, RawBytes, + BoundedArray, BoundedInt, BoundedString, ByteAngle, Decode, Encode, NbtBridge, RawBytes, Slot, VarInt, VarLong, }; use crate::text::Text; diff --git a/src/protocol/packets/c2s.rs b/src/protocol/packets/c2s.rs index ce03095..31add7f 100644 --- a/src/protocol/packets/c2s.rs +++ b/src/protocol/packets/c2s.rs @@ -98,8 +98,7 @@ pub mod login { } pub mod play { - use super::super::*; - use crate::protocol::slot::Slot; + use super::*; def_struct! { TeleportConfirm { @@ -243,15 +242,31 @@ pub mod play { } def_struct! { - ButtonClick { + ClickContainerButton { window_id: i8, button_id: i8, } } def_struct! { - ClickSlot { - // TODO + ClickContainer { + window_id: u8, + state_id: VarInt, + slot_idx: i16, + button: i8, + mode: ClickContainerMode, + } + } + + def_enum! { + ClickContainerMode: VarInt { + Click = 0, + ShiftClick = 1, + Hotbar = 2, + CreativeMiddleClick = 3, + DropKey = 4, + Drag = 5, + DoubleClick = 6, } } @@ -708,8 +723,8 @@ pub mod play { ClientStatus = 7, ClientSettings = 8, RequestCommandCompletion = 9, - ButtonClick = 10, - ClickSlot = 11, + ClickContainerButton = 10, + ClickContainer = 11, CloseHandledScreen = 12, CustomPayload = 13, BookUpdate = 14, diff --git a/src/protocol/packets/s2c.rs b/src/protocol/packets/s2c.rs index 409e88a..15a5294 100644 --- a/src/protocol/packets/s2c.rs +++ b/src/protocol/packets/s2c.rs @@ -227,6 +227,39 @@ pub mod play { } } + def_struct! { + SetContainerContent { + window_id: u8, + state_id: VarInt, + slots: Vec, + carried_item: Slot, + } + } + + def_struct! { + SetContainerProperty { + window_id: u8, + property: i16, + value: i16, + } + } + + def_struct! { + SetContainerSlot { + window_id: i8, + state_id: VarInt, + slot_idx: i16, + slot_data: Slot, + } + } + + def_struct! { + SetCooldown { + item_id: VarInt, + cooldown_ticks: VarInt, + } + } + def_enum! { SoundCategory: VarInt { Master = 0, @@ -567,6 +600,14 @@ pub mod play { } } + def_struct! { + OpenScreen { + window_id: VarInt, + window_type: VarInt, + window_title: Text, + } + } + def_struct! { ChatMessage { // TODO: more 1.19 stuff. @@ -834,6 +875,10 @@ pub mod play { BlockUpdate = 9, BossBar = 10, ClearTitles = 13, + SetContainerContent = 17, + SetContainerProperty = 18, + SetContainerSlot = 19, + SetCooldown = 20, PlaySoundId = 23, Disconnect = 25, EntityStatus = 26, @@ -845,6 +890,7 @@ pub mod play { MoveRelative = 40, RotateAndMoveRelative = 41, Rotate = 42, + OpenScreen = 45, ChatMessage = 51, UpdatePlayerList = 55, PlayerPositionLook = 57,