Skip to main content

basalt_mc_protocol/packets/play/
inventory.rs

1//! Play state — inventory packets.
2//!
3//! Auto-generated by `cargo xt codegen` from minecraft-data.
4//! Do not edit manually — changes will be overwritten.
5
6use basalt_derive::{Decode, Encode, EncodedSize, packet};
7use basalt_types::{NbtCompound, Position, Slot};
8
9// -- Serverbound packets --
10
11#[derive(Debug, Clone, Default, PartialEq)]
12#[packet(id = 0x11)]
13pub struct ServerboundPlayCloseWindow {
14    #[field(varint)]
15    pub window_id: i32,
16}
17
18#[derive(Debug, Clone, Default, PartialEq)]
19#[packet(id = 0x25)]
20pub struct ServerboundPlayCraftRecipeRequest {
21    #[field(varint)]
22    pub window_id: i32,
23    #[field(varint)]
24    pub recipe_id: i32,
25    pub make_all: bool,
26}
27
28#[derive(Debug, Clone, Default, PartialEq)]
29#[packet(id = 0x0f)]
30pub struct ServerboundPlayEnchantItem {
31    #[field(varint)]
32    pub window_id: i32,
33    pub enchantment: i8,
34}
35
36#[derive(Debug, Clone, Default, PartialEq)]
37#[packet(id = 0x33)]
38pub struct ServerboundPlayHeldItemSlot {
39    pub slot_id: i16,
40}
41
42#[derive(Debug, Clone, Default, PartialEq)]
43#[packet(id = 0x2e)]
44pub struct ServerboundPlayNameItem {
45    pub name: String,
46}
47
48#[derive(Debug, Clone, Default, PartialEq)]
49#[packet(id = 0x22)]
50pub struct ServerboundPlayPickItemFromBlock {
51    pub position: Position,
52    pub include_data: bool,
53}
54
55#[derive(Debug, Clone, Default, PartialEq)]
56#[packet(id = 0x23)]
57pub struct ServerboundPlayPickItemFromEntity {
58    #[field(varint)]
59    pub entity_id: i32,
60    pub include_data: bool,
61}
62
63#[derive(Debug, Clone, Default, PartialEq)]
64#[packet(id = 0x02)]
65pub struct ServerboundPlaySelectBundleItem {
66    #[field(varint)]
67    pub slot_id: i32,
68    #[field(varint)]
69    pub selected_item_index: i32,
70}
71
72#[derive(Debug, Clone, Default, PartialEq)]
73#[packet(id = 0x31)]
74pub struct ServerboundPlaySelectTrade {
75    #[field(varint)]
76    pub slot: i32,
77}
78
79#[derive(Debug, Clone, Default, PartialEq)]
80#[packet(id = 0x32)]
81pub struct ServerboundPlaySetBeaconEffect {
82    #[field(optional)]
83    pub primary_effect: Option<Vec<u8>>,
84    #[field(optional)]
85    pub secondary_effect: Option<Vec<u8>>,
86}
87
88#[derive(Debug, Clone, Default, PartialEq)]
89#[packet(id = 0x36)]
90pub struct ServerboundPlaySetCreativeSlot {
91    pub slot: i16,
92    pub item: Slot,
93}
94
95#[derive(Debug, Clone, Default, PartialEq)]
96#[packet(id = 0x12)]
97pub struct ServerboundPlaySetSlotState {
98    #[field(varint)]
99    pub slot_id: i32,
100    #[field(varint)]
101    pub window_id: i32,
102    pub state: bool,
103}
104
105/// Inline data structure used by [`ServerboundPlayWindowClick`].
106#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
107pub struct ServerboundPlayWindowClickChangedslots {
108    pub location: i16,
109    pub item: Slot,
110}
111
112#[derive(Debug, Clone, Default, PartialEq)]
113#[packet(id = 0x10)]
114pub struct ServerboundPlayWindowClick {
115    #[field(varint)]
116    pub window_id: i32,
117    #[field(varint)]
118    pub state_id: i32,
119    pub slot: i16,
120    pub mouse_button: i8,
121    #[field(varint)]
122    pub mode: i32,
123    #[field(length = "varint")]
124    pub changed_slots: Vec<ServerboundPlayWindowClickChangedslots>,
125    pub cursor_item: Slot,
126}
127
128// -- Clientbound packets --
129
130#[derive(Debug, Clone, Default, PartialEq)]
131#[packet(id = 0x12)]
132pub struct ClientboundPlayCloseWindow {
133    #[field(varint)]
134    pub window_id: i32,
135}
136
137#[derive(Debug, Clone, Default, PartialEq)]
138#[packet(id = 0x14)]
139pub struct ClientboundPlayCraftProgressBar {
140    #[field(varint)]
141    pub window_id: i32,
142    pub property: i16,
143    pub value: i16,
144}
145
146#[derive(Debug, Clone, Default, PartialEq)]
147#[packet(id = 0x39)]
148pub struct ClientboundPlayCraftRecipeResponse {
149    #[field(varint)]
150    pub window_id: i32,
151    pub recipe_display: crate::packets::play::types::RecipeDisplay,
152}
153
154#[derive(Debug, Clone, Default, PartialEq)]
155#[packet(id = 0x63)]
156pub struct ClientboundPlayHeldItemSlot {
157    #[field(varint)]
158    pub slot: i32,
159}
160
161#[derive(Debug, Clone, Default, PartialEq)]
162#[packet(id = 0x34)]
163pub struct ClientboundPlayOpenBook {
164    #[field(varint)]
165    pub hand: i32,
166}
167
168#[derive(Debug, Clone, Default, PartialEq)]
169#[packet(id = 0x24)]
170pub struct ClientboundPlayOpenHorseWindow {
171    #[field(varint)]
172    pub window_id: i32,
173    #[field(varint)]
174    pub nb_slots: i32,
175    pub entity_id: i32,
176}
177
178#[derive(Debug, Clone, Default, PartialEq)]
179#[packet(id = 0x36)]
180pub struct ClientboundPlayOpenSignEntity {
181    pub location: Position,
182    pub is_front_text: bool,
183}
184
185#[derive(Debug, Clone, Default, PartialEq)]
186#[packet(id = 0x35)]
187pub struct ClientboundPlayOpenWindow {
188    #[field(varint)]
189    pub window_id: i32,
190    #[field(varint)]
191    pub inventory_type: i32,
192    pub window_title: NbtCompound,
193}
194
195#[derive(Debug, Clone, Default, PartialEq)]
196#[packet(id = 0x17)]
197pub struct ClientboundPlaySetCooldown {
198    pub cooldown_group: String,
199    #[field(varint)]
200    pub cooldown_ticks: i32,
201}
202
203#[derive(Debug, Clone, Default, PartialEq)]
204#[packet(id = 0x5a)]
205pub struct ClientboundPlaySetCursorItem {
206    pub contents: Slot,
207}
208
209#[derive(Debug, Clone, Default, PartialEq)]
210#[packet(id = 0x66)]
211pub struct ClientboundPlaySetPlayerInventory {
212    #[field(varint)]
213    pub slot_id: i32,
214    pub contents: Slot,
215}
216
217#[derive(Debug, Clone, Default, PartialEq)]
218#[packet(id = 0x15)]
219pub struct ClientboundPlaySetSlot {
220    #[field(varint)]
221    pub window_id: i32,
222    #[field(varint)]
223    pub state_id: i32,
224    pub slot: i16,
225    pub item: Slot,
226}
227
228/// Inline data structure used by [`ClientboundPlayTradeList`].
229#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
230pub struct ClientboundPlayTradeListTradesInputitem1Slotcomponent {
231    #[field(varint)]
232    pub r#type: i32,
233    pub data: Vec<u8>,
234}
235
236/// Inline data structure used by [`ClientboundPlayTradeList`].
237#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
238pub struct ClientboundPlayTradeListTradesInputitem1 {
239    #[field(varint)]
240    pub item_id: i32,
241    #[field(varint)]
242    pub item_count: i32,
243    #[field(varint)]
244    pub added_component_count: i32,
245    #[field(length = "varint")]
246    pub components: Vec<ClientboundPlayTradeListTradesInputitem1Slotcomponent>,
247}
248
249/// Inline data structure used by [`ClientboundPlayTradeList`].
250#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
251pub struct ClientboundPlayTradeListTrades {
252    pub input_item1: ClientboundPlayTradeListTradesInputitem1,
253    pub output_item: Slot,
254    #[field(optional)]
255    pub input_item2: Option<Vec<u8>>,
256    pub trade_disabled: bool,
257    pub nb_trade_uses: i32,
258    pub maximum_nb_trade_uses: i32,
259    pub xp: i32,
260    pub special_price: i32,
261    pub price_multiplier: f32,
262    pub demand: i32,
263}
264
265#[derive(Debug, Clone, Default, PartialEq)]
266#[packet(id = 0x2e)]
267pub struct ClientboundPlayTradeList {
268    #[field(varint)]
269    pub window_id: i32,
270    #[field(length = "varint")]
271    pub trades: Vec<ClientboundPlayTradeListTrades>,
272    #[field(varint)]
273    pub villager_level: i32,
274    #[field(varint)]
275    pub experience: i32,
276    pub is_regular_villager: bool,
277    pub can_restock: bool,
278}
279
280#[derive(Debug, Clone, Default, PartialEq)]
281#[packet(id = 0x13)]
282pub struct ClientboundPlayWindowItems {
283    #[field(varint)]
284    pub window_id: i32,
285    #[field(varint)]
286    pub state_id: i32,
287    #[field(length = "varint")]
288    pub items: Vec<Slot>,
289    pub carried_item: Slot,
290}