chunkedge_protocol/packets/play/
set_creative_mode_slot_c2s.rs1use chunkedge_binary::{Decode, Encode};
2use chunkedge_item::{decode_item_stack_recursive, ItemStack};
3
4use crate::Packet;
5
6#[derive(Clone, Debug, Packet)]
7pub struct SetCreativeModeSlotC2s {
8 pub slot: i16,
9 pub clicked_item: ItemStack,
10}
11
12impl Decode<'_> for SetCreativeModeSlotC2s {
13 fn decode(r: &mut &[u8]) -> anyhow::Result<Self> {
14 Ok(Self {
15 slot: i16::decode(r)?,
16 clicked_item: decode_item_stack_recursive(r, 0, true)?,
17 })
18 }
19}
20
21impl Encode for SetCreativeModeSlotC2s {
22 fn encode(&self, mut w: impl std::io::Write) -> anyhow::Result<()> {
23 self.slot.encode(&mut w)?;
24 self.clicked_item.encode_recursive(w, true)
25 }
26}