Pumpkin/pumpkin-protocol/src/client/play/c_set_container_content.rs
Alexander Medvedev 03e81a1436 transfer packet id parsing to build time
This also allows now to create custom packets with a custom packet id which is not in the packets.json
2025-01-10 13:42:39 +01:00

34 lines
754 B
Rust

use crate::codec::slot::Slot;
use crate::VarInt;
use pumpkin_data::packet::clientbound::PLAY_CONTAINER_SET_CONTENT;
use pumpkin_macros::client_packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_CONTAINER_SET_CONTENT)]
pub struct CSetContainerContent<'a> {
window_id: VarInt,
state_id: VarInt,
count: VarInt,
slot_data: &'a [Slot],
carried_item: &'a Slot,
}
impl<'a> CSetContainerContent<'a> {
pub fn new(
window_id: VarInt,
state_id: VarInt,
slots: &'a [Slot],
carried_item: &'a Slot,
) -> Self {
Self {
window_id,
state_id,
count: slots.len().into(),
slot_data: slots,
carried_item,
}
}
}