1#![allow(
9 unused_imports,
10 unused_variables,
11 unused_mut,
12 unused_parens,
13 unused_braces,
14 clippy::all,
15 clippy::pedantic,
16 non_camel_case_types,
17 non_snake_case
18)]
19use crate::codec::{Decode, DecodeResult, Encode, EncodeResult, McWrite, Reader, decode_exact};
20use crate::error::{DecodeError, EncodeError};
21use crate::nbt::{AnonNbt, RawNbt};
22use crate::packet::{Direction, PacketSet, RawPacket, State};
23#[cfg(feature = "testgen")]
24use crate::testgen::{Gen, Generate};
25use crate::types::{BlockPos, ByteString, Holder, HolderSet, LpVec3, PositionLayout, Uuid};
26use bytes::{BufMut, Bytes, BytesMut};
27
28#[cfg(feature = "v26_2")]
29#[derive(Debug, Clone, PartialEq)]
31pub struct ExplosionParticleEntry {
32 pub data: crate::defs::p776::play::clientbound::ExplosionParticleInfo,
34 pub weight: i32,
36}
37#[cfg(feature = "v26_2")]
38impl Decode for ExplosionParticleEntry {
39 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
40 Ok({
41 let v1 =
42 <crate::defs::p776::play::clientbound::ExplosionParticleInfo as Decode>::decode(r)?;
43 let v2 = r.read_varint()?;
44 Self {
45 data: v1,
46 weight: v2,
47 }
48 })
49 }
50}
51#[cfg(feature = "v26_2")]
52impl Encode for ExplosionParticleEntry {
53 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
54 (*self).data.encode(w)?;
55 w.put_varint((*self).weight);
56 Ok(())
57 }
58}
59#[cfg(feature = "v26_2")]
60#[cfg(feature = "testgen")]
61impl Generate for ExplosionParticleEntry {
62 fn generate(g: &mut Gen) -> Self {
63 {
64 let v1 =
65 <crate::defs::p776::play::clientbound::ExplosionParticleInfo as Generate>::generate(
66 g,
67 );
68 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
69 Self {
70 data: v1,
71 weight: v2,
72 }
73 }
74 }
75}
76
77#[cfg(feature = "v26_2")]
78#[derive(Debug, Clone, PartialEq)]
80pub struct ExplosionParticleInfo {
81 pub particle: crate::defs::p776::types::Particle,
83 pub scaling: f32,
85 pub speed: f32,
87}
88#[cfg(feature = "v26_2")]
89impl Decode for ExplosionParticleInfo {
90 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
91 Ok({
92 let v1 = <crate::defs::p776::types::Particle as Decode>::decode(r)?;
93 let v2 = r.read_f32()?;
94 let v3 = r.read_f32()?;
95 Self {
96 particle: v1,
97 scaling: v2,
98 speed: v3,
99 }
100 })
101 }
102}
103#[cfg(feature = "v26_2")]
104impl Encode for ExplosionParticleInfo {
105 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
106 (*self).particle.encode(w)?;
107 w.put_f32((*self).scaling);
108 w.put_f32((*self).speed);
109 Ok(())
110 }
111}
112#[cfg(feature = "v26_2")]
113#[cfg(feature = "testgen")]
114impl Generate for ExplosionParticleInfo {
115 fn generate(g: &mut Gen) -> Self {
116 {
117 let v1 = <crate::defs::p776::types::Particle as Generate>::generate(g);
118 let v2 = g.f32();
119 let v3 = g.f32();
120 Self {
121 particle: v1,
122 scaling: v2,
123 speed: v3,
124 }
125 }
126 }
127}
128
129#[cfg(feature = "v26_2")]
130#[derive(Debug, Clone, PartialEq)]
132pub struct RecipeDisplayDataCraftingShapeless {
133 pub ingredients: Vec<crate::defs::p776::play::clientbound::SlotDisplay>,
135 pub result: crate::defs::p776::play::clientbound::SlotDisplay,
137 pub crafting_station: crate::defs::p776::play::clientbound::SlotDisplay,
139}
140
141#[cfg(feature = "v26_2")]
142#[derive(Debug, Clone, PartialEq)]
144pub struct RecipeDisplayDataCraftingShaped {
145 pub width: i32,
147 pub height: i32,
149 pub ingredients: Vec<crate::defs::p776::play::clientbound::SlotDisplay>,
151 pub result: crate::defs::p776::play::clientbound::SlotDisplay,
153 pub crafting_station: crate::defs::p776::play::clientbound::SlotDisplay,
155}
156
157#[cfg(feature = "v26_2")]
158#[derive(Debug, Clone, PartialEq)]
160pub struct RecipeDisplayDataFurnace {
161 pub ingredient: crate::defs::p776::play::clientbound::SlotDisplay,
163 pub fuel: crate::defs::p776::play::clientbound::SlotDisplay,
165 pub result: crate::defs::p776::play::clientbound::SlotDisplay,
167 pub crafting_station: crate::defs::p776::play::clientbound::SlotDisplay,
169 pub duration: i32,
171 pub experience: f32,
173}
174
175#[cfg(feature = "v26_2")]
176#[derive(Debug, Clone, PartialEq)]
178pub struct RecipeDisplayDataStonecutter {
179 pub ingredient: crate::defs::p776::play::clientbound::SlotDisplay,
181 pub result: crate::defs::p776::play::clientbound::SlotDisplay,
183 pub crafting_station: crate::defs::p776::play::clientbound::SlotDisplay,
185}
186
187#[cfg(feature = "v26_2")]
188#[derive(Debug, Clone, PartialEq)]
190pub struct RecipeDisplayDataSmithing {
191 pub template: crate::defs::p776::play::clientbound::SlotDisplay,
193 pub base: crate::defs::p776::play::clientbound::SlotDisplay,
195 pub addition: crate::defs::p776::play::clientbound::SlotDisplay,
197 pub result: crate::defs::p776::play::clientbound::SlotDisplay,
199 pub crafting_station: crate::defs::p776::play::clientbound::SlotDisplay,
201}
202
203#[cfg(feature = "v26_2")]
204#[derive(Debug, Clone, PartialEq)]
206#[non_exhaustive]
207pub enum RecipeDisplayData {
208 CraftingShapeless(crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShapeless),
210 CraftingShaped(crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShaped),
212 Furnace(crate::defs::p776::play::clientbound::RecipeDisplayDataFurnace),
214 Stonecutter(crate::defs::p776::play::clientbound::RecipeDisplayDataStonecutter),
216 Smithing(crate::defs::p776::play::clientbound::RecipeDisplayDataSmithing),
218 Other,
220}
221
222#[cfg(feature = "v26_2")]
223#[derive(Debug, Clone, PartialEq)]
225pub struct RecipeDisplay {
226 pub r#type: crate::defs::p775::play::clientbound::RecipeDisplayType,
228 pub data: crate::defs::p776::play::clientbound::RecipeDisplayData,
230}
231#[cfg(feature = "v26_2")]
232impl Decode for RecipeDisplay {
233 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
234 Ok({
235 let v1 = crate::defs::p775::play::clientbound::RecipeDisplayType(r.read_varint()?);
236 let v2 = (if (v1.0 == 0) {
237 crate::defs::p776::play::clientbound::RecipeDisplayData::CraftingShapeless({
238 let v3 = {
239 let v4 = {
240 let c = r.read_varint()?;
241 r.check_count(i64::from(c), 1)?
242 };
243 let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
244 for _ in 0..v4 {
245 v5.push(<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?);
246 }
247 v5
248 };
249 let v6 =
250 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
251 let v7 =
252 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
253 crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShapeless {
254 ingredients: v3,
255 result: v6,
256 crafting_station: v7,
257 }
258 })
259 } else if (v1.0 == 1) {
260 crate::defs::p776::play::clientbound::RecipeDisplayData::CraftingShaped({
261 let v8 = r.read_varint()?;
262 let v9 = r.read_varint()?;
263 let v10 = {
264 let v11 = {
265 let c = r.read_varint()?;
266 r.check_count(i64::from(c), 1)?
267 };
268 let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
269 for _ in 0..v11 {
270 v12.push(<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?);
271 }
272 v12
273 };
274 let v13 =
275 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
276 let v14 =
277 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
278 crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShaped {
279 width: v8,
280 height: v9,
281 ingredients: v10,
282 result: v13,
283 crafting_station: v14,
284 }
285 })
286 } else if (v1.0 == 2) {
287 crate::defs::p776::play::clientbound::RecipeDisplayData::Furnace({
288 let v15 =
289 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
290 let v16 =
291 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
292 let v17 =
293 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
294 let v18 =
295 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
296 let v19 = r.read_varint()?;
297 let v20 = r.read_f32()?;
298 crate::defs::p776::play::clientbound::RecipeDisplayDataFurnace {
299 ingredient: v15,
300 fuel: v16,
301 result: v17,
302 crafting_station: v18,
303 duration: v19,
304 experience: v20,
305 }
306 })
307 } else if (v1.0 == 3) {
308 crate::defs::p776::play::clientbound::RecipeDisplayData::Stonecutter({
309 let v21 =
310 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
311 let v22 =
312 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
313 let v23 =
314 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
315 crate::defs::p776::play::clientbound::RecipeDisplayDataStonecutter {
316 ingredient: v21,
317 result: v22,
318 crafting_station: v23,
319 }
320 })
321 } else if (v1.0 == 4) {
322 crate::defs::p776::play::clientbound::RecipeDisplayData::Smithing({
323 let v24 =
324 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
325 let v25 =
326 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
327 let v26 =
328 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
329 let v27 =
330 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
331 let v28 =
332 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
333 crate::defs::p776::play::clientbound::RecipeDisplayDataSmithing {
334 template: v24,
335 base: v25,
336 addition: v26,
337 result: v27,
338 crafting_station: v28,
339 }
340 })
341 } else {
342 crate::defs::p776::play::clientbound::RecipeDisplayData::Other
343 });
344 Self {
345 r#type: v1,
346 data: v2,
347 }
348 })
349 }
350}
351#[cfg(feature = "v26_2")]
352impl Encode for RecipeDisplay {
353 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
354 w.put_varint((*self).r#type.0);
355 match &(*self).data {
356 crate::defs::p776::play::clientbound::RecipeDisplayData::CraftingShapeless(v1) => {
357 if !((*self).r#type.0 == 0) {
358 return Err(EncodeError::SwitchMismatch(
359 "play.clientbound.RecipeDisplay.data",
360 ));
361 }
362 w.put_len_varint((*v1).ingredients.len())?;
363 for v2 in (*v1).ingredients.iter() {
364 (*v2).encode(w)?;
365 }
366 (*v1).result.encode(w)?;
367 (*v1).crafting_station.encode(w)?;
368 }
369 crate::defs::p776::play::clientbound::RecipeDisplayData::CraftingShaped(v3) => {
370 if !((*self).r#type.0 == 1) {
371 return Err(EncodeError::SwitchMismatch(
372 "play.clientbound.RecipeDisplay.data",
373 ));
374 }
375 w.put_varint((*v3).width);
376 w.put_varint((*v3).height);
377 w.put_len_varint((*v3).ingredients.len())?;
378 for v4 in (*v3).ingredients.iter() {
379 (*v4).encode(w)?;
380 }
381 (*v3).result.encode(w)?;
382 (*v3).crafting_station.encode(w)?;
383 }
384 crate::defs::p776::play::clientbound::RecipeDisplayData::Furnace(v5) => {
385 if !((*self).r#type.0 == 2) {
386 return Err(EncodeError::SwitchMismatch(
387 "play.clientbound.RecipeDisplay.data",
388 ));
389 }
390 (*v5).ingredient.encode(w)?;
391 (*v5).fuel.encode(w)?;
392 (*v5).result.encode(w)?;
393 (*v5).crafting_station.encode(w)?;
394 w.put_varint((*v5).duration);
395 w.put_f32((*v5).experience);
396 }
397 crate::defs::p776::play::clientbound::RecipeDisplayData::Stonecutter(v6) => {
398 if !((*self).r#type.0 == 3) {
399 return Err(EncodeError::SwitchMismatch(
400 "play.clientbound.RecipeDisplay.data",
401 ));
402 }
403 (*v6).ingredient.encode(w)?;
404 (*v6).result.encode(w)?;
405 (*v6).crafting_station.encode(w)?;
406 }
407 crate::defs::p776::play::clientbound::RecipeDisplayData::Smithing(v7) => {
408 if !((*self).r#type.0 == 4) {
409 return Err(EncodeError::SwitchMismatch(
410 "play.clientbound.RecipeDisplay.data",
411 ));
412 }
413 (*v7).template.encode(w)?;
414 (*v7).base.encode(w)?;
415 (*v7).addition.encode(w)?;
416 (*v7).result.encode(w)?;
417 (*v7).crafting_station.encode(w)?;
418 }
419 crate::defs::p776::play::clientbound::RecipeDisplayData::Other => {
420 if !(!(((*self).r#type.0 == 0)
421 || ((*self).r#type.0 == 1)
422 || ((*self).r#type.0 == 2)
423 || ((*self).r#type.0 == 3)
424 || ((*self).r#type.0 == 4)))
425 {
426 return Err(EncodeError::SwitchMismatch(
427 "play.clientbound.RecipeDisplay.data",
428 ));
429 }
430 }
431 }
432 Ok(())
433 }
434}
435#[cfg(feature = "v26_2")]
436#[cfg(feature = "testgen")]
437impl Generate for RecipeDisplay {
438 fn generate(g: &mut Gen) -> Self {
439 {
440 let v1 = crate::defs::p775::play::clientbound::RecipeDisplayType(g.int_in(
441 -2147483648,
442 2147483647,
443 &[0, 1, 2, 3, 4],
444 ) as i32);
445 let v2 = (if (v1.0 == 0) {
446 crate::defs::p776::play::clientbound::RecipeDisplayData::CraftingShapeless({
447 let v3 = {
448 let v4 = g.count();
449 let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
450 for _ in 0..v4 {
451 v5.push(<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(g));
452 }
453 v5
454 };
455 let v6 =
456 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
457 g,
458 );
459 let v7 =
460 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
461 g,
462 );
463 crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShapeless {
464 ingredients: v3,
465 result: v6,
466 crafting_station: v7,
467 }
468 })
469 } else if (v1.0 == 1) {
470 crate::defs::p776::play::clientbound::RecipeDisplayData::CraftingShaped({
471 let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
472 let v9 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
473 let v10 = {
474 let v11 = g.count();
475 let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
476 for _ in 0..v11 {
477 v12.push(<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(g));
478 }
479 v12
480 };
481 let v13 =
482 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
483 g,
484 );
485 let v14 =
486 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
487 g,
488 );
489 crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShaped {
490 width: v8,
491 height: v9,
492 ingredients: v10,
493 result: v13,
494 crafting_station: v14,
495 }
496 })
497 } else if (v1.0 == 2) {
498 crate::defs::p776::play::clientbound::RecipeDisplayData::Furnace({
499 let v15 =
500 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
501 g,
502 );
503 let v16 =
504 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
505 g,
506 );
507 let v17 =
508 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
509 g,
510 );
511 let v18 =
512 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
513 g,
514 );
515 let v19 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
516 let v20 = g.f32();
517 crate::defs::p776::play::clientbound::RecipeDisplayDataFurnace {
518 ingredient: v15,
519 fuel: v16,
520 result: v17,
521 crafting_station: v18,
522 duration: v19,
523 experience: v20,
524 }
525 })
526 } else if (v1.0 == 3) {
527 crate::defs::p776::play::clientbound::RecipeDisplayData::Stonecutter({
528 let v21 =
529 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
530 g,
531 );
532 let v22 =
533 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
534 g,
535 );
536 let v23 =
537 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
538 g,
539 );
540 crate::defs::p776::play::clientbound::RecipeDisplayDataStonecutter {
541 ingredient: v21,
542 result: v22,
543 crafting_station: v23,
544 }
545 })
546 } else if (v1.0 == 4) {
547 crate::defs::p776::play::clientbound::RecipeDisplayData::Smithing({
548 let v24 =
549 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
550 g,
551 );
552 let v25 =
553 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
554 g,
555 );
556 let v26 =
557 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
558 g,
559 );
560 let v27 =
561 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
562 g,
563 );
564 let v28 =
565 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
566 g,
567 );
568 crate::defs::p776::play::clientbound::RecipeDisplayDataSmithing {
569 template: v24,
570 base: v25,
571 addition: v26,
572 result: v27,
573 crafting_station: v28,
574 }
575 })
576 } else {
577 crate::defs::p776::play::clientbound::RecipeDisplayData::Other
578 });
579 Self {
580 r#type: v1,
581 data: v2,
582 }
583 }
584 }
585}
586
587#[cfg(feature = "v26_2")]
588#[derive(Debug, Clone, PartialEq)]
590pub struct SlotDisplayDataWithAnyPotion {
591 pub base: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
593}
594
595#[cfg(feature = "v26_2")]
596#[derive(Debug, Clone, PartialEq)]
598pub struct SlotDisplayDataOnlyWithComponent {
599 pub source: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
601 pub component: crate::defs::p776::types::SlotComponentType,
603}
604
605#[cfg(feature = "v26_2")]
606#[derive(Debug, Clone, PartialEq)]
608pub struct SlotDisplayDataDyedSlotDemo {
609 pub dye: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
611 pub target: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
613}
614
615#[cfg(feature = "v26_2")]
616#[derive(Debug, Clone, PartialEq)]
618pub struct SlotDisplayDataSmithingTrim {
619 pub base: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
621 pub material: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
623 pub pattern: Holder<crate::defs::p775::types::ArmorTrimPattern>,
625}
626
627#[cfg(feature = "v26_2")]
628#[derive(Debug, Clone, PartialEq)]
630pub struct SlotDisplayDataWithRemainder {
631 pub input: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
633 pub remainder: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
635}
636
637#[cfg(feature = "v26_2")]
638#[derive(Debug, Clone, PartialEq)]
640#[non_exhaustive]
641pub enum SlotDisplayData {
642 Empty,
644 AnyFuel,
646 WithAnyPotion(crate::defs::p776::play::clientbound::SlotDisplayDataWithAnyPotion),
648 OnlyWithComponent(crate::defs::p776::play::clientbound::SlotDisplayDataOnlyWithComponent),
650 Item(i32),
652 ItemStack(crate::defs::p776::types::ItemStackTemplate),
654 Tag(ByteString),
656 DyedSlotDemo(crate::defs::p776::play::clientbound::SlotDisplayDataDyedSlotDemo),
658 SmithingTrim(crate::defs::p776::play::clientbound::SlotDisplayDataSmithingTrim),
660 WithRemainder(crate::defs::p776::play::clientbound::SlotDisplayDataWithRemainder),
662 Composite(Vec<crate::defs::p776::play::clientbound::SlotDisplay>),
664 Other,
666}
667
668#[cfg(feature = "v26_2")]
669#[derive(Debug, Clone, PartialEq)]
671pub struct SlotDisplay {
672 pub r#type: crate::defs::p775::play::clientbound::SlotDisplayType,
674 pub data: crate::defs::p776::play::clientbound::SlotDisplayData,
676}
677#[cfg(feature = "v26_2")]
678impl Decode for SlotDisplay {
679 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
680 Ok({
681 let v1 = crate::defs::p775::play::clientbound::SlotDisplayType(r.read_varint()?);
682 let v2 = (if (v1.0 == 0) {
683 crate::defs::p776::play::clientbound::SlotDisplayData::Empty
684 } else if (v1.0 == 1) {
685 crate::defs::p776::play::clientbound::SlotDisplayData::AnyFuel
686 } else if (v1.0 == 2) {
687 crate::defs::p776::play::clientbound::SlotDisplayData::WithAnyPotion({
688 let v3 = Box::new(
689 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
690 );
691 crate::defs::p776::play::clientbound::SlotDisplayDataWithAnyPotion { base: v3 }
692 })
693 } else if (v1.0 == 3) {
694 crate::defs::p776::play::clientbound::SlotDisplayData::OnlyWithComponent({
695 let v4 = Box::new(
696 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
697 );
698 let v5 = crate::defs::p776::types::SlotComponentType(r.read_varint()?);
699 crate::defs::p776::play::clientbound::SlotDisplayDataOnlyWithComponent {
700 source: v4,
701 component: v5,
702 }
703 })
704 } else if (v1.0 == 4) {
705 crate::defs::p776::play::clientbound::SlotDisplayData::Item(r.read_varint()?)
706 } else if (v1.0 == 5) {
707 crate::defs::p776::play::clientbound::SlotDisplayData::ItemStack(
708 <crate::defs::p776::types::ItemStackTemplate as Decode>::decode(r)?,
709 )
710 } else if (v1.0 == 6) {
711 crate::defs::p776::play::clientbound::SlotDisplayData::Tag(r.read_string()?)
712 } else if (v1.0 == 7) {
713 crate::defs::p776::play::clientbound::SlotDisplayData::DyedSlotDemo({
714 let v6 = Box::new(
715 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
716 );
717 let v7 = Box::new(
718 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
719 );
720 crate::defs::p776::play::clientbound::SlotDisplayDataDyedSlotDemo {
721 dye: v6,
722 target: v7,
723 }
724 })
725 } else if (v1.0 == 8) {
726 crate::defs::p776::play::clientbound::SlotDisplayData::SmithingTrim({
727 let v8 = Box::new(
728 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
729 );
730 let v9 = Box::new(
731 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
732 );
733 let v10 = {
734 let id = r.read_varint()?;
735 if id == 0 {
736 Holder::Inline(
737 <crate::defs::p775::types::ArmorTrimPattern as Decode>::decode(r)?,
738 )
739 } else {
740 Holder::Id(id.wrapping_sub(1))
741 }
742 };
743 crate::defs::p776::play::clientbound::SlotDisplayDataSmithingTrim {
744 base: v8,
745 material: v9,
746 pattern: v10,
747 }
748 })
749 } else if (v1.0 == 9) {
750 crate::defs::p776::play::clientbound::SlotDisplayData::WithRemainder({
751 let v11 = Box::new(
752 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
753 );
754 let v12 = Box::new(
755 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
756 );
757 crate::defs::p776::play::clientbound::SlotDisplayDataWithRemainder {
758 input: v11,
759 remainder: v12,
760 }
761 })
762 } else if (v1.0 == 10) {
763 crate::defs::p776::play::clientbound::SlotDisplayData::Composite({
764 let v13 = {
765 let c = r.read_varint()?;
766 r.check_count(i64::from(c), 1)?
767 };
768 let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
769 for _ in 0..v13 {
770 v14.push(
771 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(
772 r,
773 )?,
774 );
775 }
776 v14
777 })
778 } else {
779 crate::defs::p776::play::clientbound::SlotDisplayData::Other
780 });
781 Self {
782 r#type: v1,
783 data: v2,
784 }
785 })
786 }
787}
788#[cfg(feature = "v26_2")]
789impl Encode for SlotDisplay {
790 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
791 w.put_varint((*self).r#type.0);
792 match &(*self).data {
793 crate::defs::p776::play::clientbound::SlotDisplayData::Empty => {
794 if !((*self).r#type.0 == 0) {
795 return Err(EncodeError::SwitchMismatch(
796 "play.clientbound.SlotDisplay.data",
797 ));
798 }
799 }
800 crate::defs::p776::play::clientbound::SlotDisplayData::AnyFuel => {
801 if !((*self).r#type.0 == 1) {
802 return Err(EncodeError::SwitchMismatch(
803 "play.clientbound.SlotDisplay.data",
804 ));
805 }
806 }
807 crate::defs::p776::play::clientbound::SlotDisplayData::WithAnyPotion(v1) => {
808 if !((*self).r#type.0 == 2) {
809 return Err(EncodeError::SwitchMismatch(
810 "play.clientbound.SlotDisplay.data",
811 ));
812 }
813 (*(*v1).base).encode(w)?;
814 }
815 crate::defs::p776::play::clientbound::SlotDisplayData::OnlyWithComponent(v2) => {
816 if !((*self).r#type.0 == 3) {
817 return Err(EncodeError::SwitchMismatch(
818 "play.clientbound.SlotDisplay.data",
819 ));
820 }
821 (*(*v2).source).encode(w)?;
822 w.put_varint((*v2).component.0);
823 }
824 crate::defs::p776::play::clientbound::SlotDisplayData::Item(v3) => {
825 if !((*self).r#type.0 == 4) {
826 return Err(EncodeError::SwitchMismatch(
827 "play.clientbound.SlotDisplay.data",
828 ));
829 }
830 w.put_varint((*v3));
831 }
832 crate::defs::p776::play::clientbound::SlotDisplayData::ItemStack(v4) => {
833 if !((*self).r#type.0 == 5) {
834 return Err(EncodeError::SwitchMismatch(
835 "play.clientbound.SlotDisplay.data",
836 ));
837 }
838 (*v4).encode(w)?;
839 }
840 crate::defs::p776::play::clientbound::SlotDisplayData::Tag(v5) => {
841 if !((*self).r#type.0 == 6) {
842 return Err(EncodeError::SwitchMismatch(
843 "play.clientbound.SlotDisplay.data",
844 ));
845 }
846 w.put_string(&(*v5))?;
847 }
848 crate::defs::p776::play::clientbound::SlotDisplayData::DyedSlotDemo(v6) => {
849 if !((*self).r#type.0 == 7) {
850 return Err(EncodeError::SwitchMismatch(
851 "play.clientbound.SlotDisplay.data",
852 ));
853 }
854 (*(*v6).dye).encode(w)?;
855 (*(*v6).target).encode(w)?;
856 }
857 crate::defs::p776::play::clientbound::SlotDisplayData::SmithingTrim(v7) => {
858 if !((*self).r#type.0 == 8) {
859 return Err(EncodeError::SwitchMismatch(
860 "play.clientbound.SlotDisplay.data",
861 ));
862 }
863 (*(*v7).base).encode(w)?;
864 (*(*v7).material).encode(w)?;
865 match &(*v7).pattern {
866 Holder::Id(v9) => {
867 if *v9 == -1 {
868 return Err(EncodeError::OutOfRange("holder id"));
869 }
870 w.put_varint(v9.wrapping_add(1));
871 }
872 Holder::Inline(v8) => {
873 w.put_varint(0);
874 (*v8).encode(w)?;
875 }
876 }
877 }
878 crate::defs::p776::play::clientbound::SlotDisplayData::WithRemainder(v10) => {
879 if !((*self).r#type.0 == 9) {
880 return Err(EncodeError::SwitchMismatch(
881 "play.clientbound.SlotDisplay.data",
882 ));
883 }
884 (*(*v10).input).encode(w)?;
885 (*(*v10).remainder).encode(w)?;
886 }
887 crate::defs::p776::play::clientbound::SlotDisplayData::Composite(v11) => {
888 if !((*self).r#type.0 == 10) {
889 return Err(EncodeError::SwitchMismatch(
890 "play.clientbound.SlotDisplay.data",
891 ));
892 }
893 w.put_len_varint((*v11).len())?;
894 for v12 in (*v11).iter() {
895 (*v12).encode(w)?;
896 }
897 }
898 crate::defs::p776::play::clientbound::SlotDisplayData::Other => {
899 if !(!(((*self).r#type.0 == 0)
900 || ((*self).r#type.0 == 1)
901 || ((*self).r#type.0 == 2)
902 || ((*self).r#type.0 == 3)
903 || ((*self).r#type.0 == 4)
904 || ((*self).r#type.0 == 5)
905 || ((*self).r#type.0 == 6)
906 || ((*self).r#type.0 == 7)
907 || ((*self).r#type.0 == 8)
908 || ((*self).r#type.0 == 9)
909 || ((*self).r#type.0 == 10)))
910 {
911 return Err(EncodeError::SwitchMismatch(
912 "play.clientbound.SlotDisplay.data",
913 ));
914 }
915 }
916 }
917 Ok(())
918 }
919}
920#[cfg(feature = "v26_2")]
921#[cfg(feature = "testgen")]
922impl Generate for SlotDisplay {
923 fn generate(g: &mut Gen) -> Self {
924 {
925 let v1 = crate::defs::p775::play::clientbound::SlotDisplayType(g.int_in(
926 -2147483648,
927 2147483647,
928 &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
929 ) as i32);
930 let v2 = (if (v1.0 == 0) {
931 crate::defs::p776::play::clientbound::SlotDisplayData::Empty
932 } else if (v1.0 == 1) {
933 crate::defs::p776::play::clientbound::SlotDisplayData::AnyFuel
934 } else if (v1.0 == 2) {
935 crate::defs::p776::play::clientbound::SlotDisplayData::WithAnyPotion({
936 let v3 = Box::new(
937 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
938 g,
939 ),
940 );
941 crate::defs::p776::play::clientbound::SlotDisplayDataWithAnyPotion { base: v3 }
942 })
943 } else if (v1.0 == 3) {
944 crate::defs::p776::play::clientbound::SlotDisplayData::OnlyWithComponent({
945 let v4 = Box::new(
946 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
947 g,
948 ),
949 );
950 let v5 = crate::defs::p776::types::SlotComponentType(g.int_in(
951 -2147483648,
952 2147483647,
953 &[
954 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
955 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
956 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
957 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
958 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
959 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
960 108, 109, 110,
961 ],
962 )
963 as i32);
964 crate::defs::p776::play::clientbound::SlotDisplayDataOnlyWithComponent {
965 source: v4,
966 component: v5,
967 }
968 })
969 } else if (v1.0 == 4) {
970 crate::defs::p776::play::clientbound::SlotDisplayData::Item(
971 (g.int_in(-2147483648, 2147483647, &[]) as i32),
972 )
973 } else if (v1.0 == 5) {
974 crate::defs::p776::play::clientbound::SlotDisplayData::ItemStack(
975 <crate::defs::p776::types::ItemStackTemplate as Generate>::generate(g),
976 )
977 } else if (v1.0 == 6) {
978 crate::defs::p776::play::clientbound::SlotDisplayData::Tag(g.string())
979 } else if (v1.0 == 7) {
980 crate::defs::p776::play::clientbound::SlotDisplayData::DyedSlotDemo({
981 let v6 = Box::new(
982 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
983 g,
984 ),
985 );
986 let v7 = Box::new(
987 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
988 g,
989 ),
990 );
991 crate::defs::p776::play::clientbound::SlotDisplayDataDyedSlotDemo {
992 dye: v6,
993 target: v7,
994 }
995 })
996 } else if (v1.0 == 8) {
997 crate::defs::p776::play::clientbound::SlotDisplayData::SmithingTrim({
998 let v8 = Box::new(
999 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
1000 g,
1001 ),
1002 );
1003 let v9 = Box::new(
1004 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
1005 g,
1006 ),
1007 );
1008 let v10 = if g.bool() {
1009 Holder::Id(match g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32 {
1010 -1 => 0,
1011 v => v,
1012 })
1013 } else {
1014 Holder::Inline(
1015 <crate::defs::p775::types::ArmorTrimPattern as Generate>::generate(g),
1016 )
1017 };
1018 crate::defs::p776::play::clientbound::SlotDisplayDataSmithingTrim {
1019 base: v8,
1020 material: v9,
1021 pattern: v10,
1022 }
1023 })
1024 } else if (v1.0 == 9) {
1025 crate::defs::p776::play::clientbound::SlotDisplayData::WithRemainder({
1026 let v11 = Box::new(
1027 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
1028 g,
1029 ),
1030 );
1031 let v12 = Box::new(
1032 <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
1033 g,
1034 ),
1035 );
1036 crate::defs::p776::play::clientbound::SlotDisplayDataWithRemainder {
1037 input: v11,
1038 remainder: v12,
1039 }
1040 })
1041 } else if (v1.0 == 10) {
1042 crate::defs::p776::play::clientbound::SlotDisplayData::Composite({
1043 let v13 = g.count();
1044 let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
1045 for _ in 0..v13 {
1046 v14.push(<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(g));
1047 }
1048 v14
1049 })
1050 } else {
1051 crate::defs::p776::play::clientbound::SlotDisplayData::Other
1052 });
1053 Self {
1054 r#type: v1,
1055 data: v2,
1056 }
1057 }
1058 }
1059}
1060
1061#[cfg(feature = "v26_2")]
1062#[derive(Debug, Clone, PartialEq)]
1064pub struct DeclareCommands<const V: i32> {
1065 pub nodes: Vec<crate::defs::p776::types::CommandNode>,
1067 pub root_index: i32,
1069}
1070#[cfg(feature = "v26_2")]
1071impl<const V: i32> Decode for DeclareCommands<V> {
1072 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1073 Ok({
1074 let v1 = {
1075 let v2 = {
1076 let c = r.read_varint()?;
1077 r.check_count(i64::from(c), 2)?
1078 };
1079 let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
1080 for _ in 0..v2 {
1081 v3.push(<crate::defs::p776::types::CommandNode as Decode>::decode(
1082 r,
1083 )?);
1084 }
1085 v3
1086 };
1087 let v4 = r.read_varint()?;
1088 Self {
1089 nodes: v1,
1090 root_index: v4,
1091 }
1092 })
1093 }
1094}
1095#[cfg(feature = "v26_2")]
1096impl<const V: i32> Encode for DeclareCommands<V> {
1097 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1098 w.put_len_varint((*self).nodes.len())?;
1099 for v1 in (*self).nodes.iter() {
1100 (*v1).encode(w)?;
1101 }
1102 w.put_varint((*self).root_index);
1103 Ok(())
1104 }
1105}
1106#[cfg(feature = "v26_2")]
1107#[cfg(feature = "testgen")]
1108impl<const V: i32> Generate for DeclareCommands<V> {
1109 fn generate(g: &mut Gen) -> Self {
1110 {
1111 let v1 = {
1112 let v2 = g.count();
1113 let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
1114 for _ in 0..v2 {
1115 v3.push(<crate::defs::p776::types::CommandNode as Generate>::generate(g));
1116 }
1117 v3
1118 };
1119 let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1120 Self {
1121 nodes: v1,
1122 root_index: v4,
1123 }
1124 }
1125 }
1126}
1127
1128#[cfg(feature = "v26_2")]
1129#[derive(Debug, Clone, PartialEq)]
1131pub struct WindowItems<const V: i32> {
1132 pub window_id: i32,
1134 pub state_id: i32,
1136 pub items: Vec<crate::defs::p776::types::Slot>,
1138 pub carried_item: crate::defs::p776::types::Slot,
1140}
1141#[cfg(feature = "v26_2")]
1142impl<const V: i32> Decode for WindowItems<V> {
1143 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1144 Ok({
1145 let v1 = r.read_varint()?;
1146 let v2 = r.read_varint()?;
1147 let v3 = {
1148 let v4 = {
1149 let c = r.read_varint()?;
1150 r.check_count(i64::from(c), 1)?
1151 };
1152 let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
1153 for _ in 0..v4 {
1154 v5.push(<crate::defs::p776::types::Slot as Decode>::decode(r)?);
1155 }
1156 v5
1157 };
1158 let v6 = <crate::defs::p776::types::Slot as Decode>::decode(r)?;
1159 Self {
1160 window_id: v1,
1161 state_id: v2,
1162 items: v3,
1163 carried_item: v6,
1164 }
1165 })
1166 }
1167}
1168#[cfg(feature = "v26_2")]
1169impl<const V: i32> Encode for WindowItems<V> {
1170 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1171 w.put_varint((*self).window_id);
1172 w.put_varint((*self).state_id);
1173 w.put_len_varint((*self).items.len())?;
1174 for v1 in (*self).items.iter() {
1175 (*v1).encode(w)?;
1176 }
1177 (*self).carried_item.encode(w)?;
1178 Ok(())
1179 }
1180}
1181#[cfg(feature = "v26_2")]
1182#[cfg(feature = "testgen")]
1183impl<const V: i32> Generate for WindowItems<V> {
1184 fn generate(g: &mut Gen) -> Self {
1185 {
1186 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1187 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1188 let v3 = {
1189 let v4 = g.count();
1190 let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
1191 for _ in 0..v4 {
1192 v5.push(<crate::defs::p776::types::Slot as Generate>::generate(g));
1193 }
1194 v5
1195 };
1196 let v6 = <crate::defs::p776::types::Slot as Generate>::generate(g);
1197 Self {
1198 window_id: v1,
1199 state_id: v2,
1200 items: v3,
1201 carried_item: v6,
1202 }
1203 }
1204 }
1205}
1206
1207#[cfg(feature = "v26_2")]
1208#[derive(Debug, Clone, PartialEq)]
1210pub struct SetSlot<const V: i32> {
1211 pub window_id: i32,
1213 pub state_id: i32,
1215 pub slot: i16,
1217 pub item: crate::defs::p776::types::Slot,
1219}
1220#[cfg(feature = "v26_2")]
1221impl<const V: i32> Decode for SetSlot<V> {
1222 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1223 Ok({
1224 let v1 = r.read_varint()?;
1225 let v2 = r.read_varint()?;
1226 let v3 = r.read_i16()?;
1227 let v4 = <crate::defs::p776::types::Slot as Decode>::decode(r)?;
1228 Self {
1229 window_id: v1,
1230 state_id: v2,
1231 slot: v3,
1232 item: v4,
1233 }
1234 })
1235 }
1236}
1237#[cfg(feature = "v26_2")]
1238impl<const V: i32> Encode for SetSlot<V> {
1239 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1240 w.put_varint((*self).window_id);
1241 w.put_varint((*self).state_id);
1242 w.put_i16((*self).slot);
1243 (*self).item.encode(w)?;
1244 Ok(())
1245 }
1246}
1247#[cfg(feature = "v26_2")]
1248#[cfg(feature = "testgen")]
1249impl<const V: i32> Generate for SetSlot<V> {
1250 fn generate(g: &mut Gen) -> Self {
1251 {
1252 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1253 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1254 let v3 = (g.int_in(-32768, 32767, &[]) as i16);
1255 let v4 = <crate::defs::p776::types::Slot as Generate>::generate(g);
1256 Self {
1257 window_id: v1,
1258 state_id: v2,
1259 slot: v3,
1260 item: v4,
1261 }
1262 }
1263 }
1264}
1265
1266#[cfg(feature = "v26_2")]
1267#[derive(Debug, Clone, PartialEq)]
1269pub struct Explosion<const V: i32> {
1270 pub center: crate::defs::p775::types::Vec3f64,
1272 pub radius: f32,
1274 pub block_count: i32,
1276 pub player_knockback: Option<crate::defs::p775::types::Vec3f64>,
1278 pub explosion_particle: crate::defs::p776::types::Particle,
1280 pub sound: Holder<crate::defs::p775::types::ItemSoundEvent>,
1282 pub block_particles: Vec<crate::defs::p776::play::clientbound::ExplosionParticleEntry>,
1284}
1285#[cfg(feature = "v26_2")]
1286impl<const V: i32> Decode for Explosion<V> {
1287 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1288 Ok({
1289 let v1 = <crate::defs::p775::types::Vec3f64 as Decode>::decode(r)?;
1290 let v2 = r.read_f32()?;
1291 let v3 = r.read_i32()?;
1292 let v4 = if r.read_bool()? {
1293 Some(<crate::defs::p775::types::Vec3f64 as Decode>::decode(r)?)
1294 } else {
1295 None
1296 };
1297 let v5 = <crate::defs::p776::types::Particle as Decode>::decode(r)?;
1298 let v6 = {
1299 let id = r.read_varint()?;
1300 if id == 0 {
1301 Holder::Inline(<crate::defs::p775::types::ItemSoundEvent as Decode>::decode(r)?)
1302 } else {
1303 Holder::Id(id.wrapping_sub(1))
1304 }
1305 };
1306 let v7 = {
1307 let v8 = {
1308 let c = r.read_varint()?;
1309 r.check_count(i64::from(c), 10)?
1310 };
1311 let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT));
1312 for _ in 0..v8 {
1313 v9.push(<crate::defs::p776::play::clientbound::ExplosionParticleEntry as Decode>::decode(r)?);
1314 }
1315 v9
1316 };
1317 Self {
1318 center: v1,
1319 radius: v2,
1320 block_count: v3,
1321 player_knockback: v4,
1322 explosion_particle: v5,
1323 sound: v6,
1324 block_particles: v7,
1325 }
1326 })
1327 }
1328}
1329#[cfg(feature = "v26_2")]
1330impl<const V: i32> Encode for Explosion<V> {
1331 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1332 (*self).center.encode(w)?;
1333 w.put_f32((*self).radius);
1334 w.put_i32((*self).block_count);
1335 match &(*self).player_knockback {
1336 Some(v1) => {
1337 w.put_u8(1);
1338 (*v1).encode(w)?;
1339 }
1340 None => w.put_u8(0),
1341 }
1342 (*self).explosion_particle.encode(w)?;
1343 match &(*self).sound {
1344 Holder::Id(v3) => {
1345 if *v3 == -1 {
1346 return Err(EncodeError::OutOfRange("holder id"));
1347 }
1348 w.put_varint(v3.wrapping_add(1));
1349 }
1350 Holder::Inline(v2) => {
1351 w.put_varint(0);
1352 (*v2).encode(w)?;
1353 }
1354 }
1355 w.put_len_varint((*self).block_particles.len())?;
1356 for v4 in (*self).block_particles.iter() {
1357 (*v4).encode(w)?;
1358 }
1359 Ok(())
1360 }
1361}
1362#[cfg(feature = "v26_2")]
1363#[cfg(feature = "testgen")]
1364impl<const V: i32> Generate for Explosion<V> {
1365 fn generate(g: &mut Gen) -> Self {
1366 {
1367 let v1 = <crate::defs::p775::types::Vec3f64 as Generate>::generate(g);
1368 let v2 = g.f32();
1369 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1370 let v4 = if g.bool() {
1371 Some(<crate::defs::p775::types::Vec3f64 as Generate>::generate(g))
1372 } else {
1373 None
1374 };
1375 let v5 = <crate::defs::p776::types::Particle as Generate>::generate(g);
1376 let v6 = if g.bool() {
1377 Holder::Id(match g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32 {
1378 -1 => 0,
1379 v => v,
1380 })
1381 } else {
1382 Holder::Inline(<crate::defs::p775::types::ItemSoundEvent as Generate>::generate(g))
1383 };
1384 let v7 = {
1385 let v8 = g.count();
1386 let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT));
1387 for _ in 0..v8 {
1388 v9.push(<crate::defs::p776::play::clientbound::ExplosionParticleEntry as Generate>::generate(g));
1389 }
1390 v9
1391 };
1392 Self {
1393 center: v1,
1394 radius: v2,
1395 block_count: v3,
1396 player_knockback: v4,
1397 explosion_particle: v5,
1398 sound: v6,
1399 block_particles: v7,
1400 }
1401 }
1402 }
1403}
1404
1405#[cfg(feature = "v26_2")]
1406#[derive(Debug, Clone, PartialEq)]
1408pub struct WorldParticles<const V: i32> {
1409 pub long_distance: bool,
1411 pub always_show: bool,
1413 pub x: f64,
1415 pub y: f64,
1417 pub z: f64,
1419 pub offset_x: f32,
1421 pub offset_y: f32,
1423 pub offset_z: f32,
1425 pub velocity_offset: f32,
1427 pub amount: i32,
1429 pub particle: crate::defs::p776::types::Particle,
1431}
1432#[cfg(feature = "v26_2")]
1433impl<const V: i32> Decode for WorldParticles<V> {
1434 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1435 Ok({
1436 let v1 = r.read_bool()?;
1437 let v2 = r.read_bool()?;
1438 let v3 = r.read_f64()?;
1439 let v4 = r.read_f64()?;
1440 let v5 = r.read_f64()?;
1441 let v6 = r.read_f32()?;
1442 let v7 = r.read_f32()?;
1443 let v8 = r.read_f32()?;
1444 let v9 = r.read_f32()?;
1445 let v10 = r.read_i32()?;
1446 let v11 = <crate::defs::p776::types::Particle as Decode>::decode(r)?;
1447 Self {
1448 long_distance: v1,
1449 always_show: v2,
1450 x: v3,
1451 y: v4,
1452 z: v5,
1453 offset_x: v6,
1454 offset_y: v7,
1455 offset_z: v8,
1456 velocity_offset: v9,
1457 amount: v10,
1458 particle: v11,
1459 }
1460 })
1461 }
1462}
1463#[cfg(feature = "v26_2")]
1464impl<const V: i32> Encode for WorldParticles<V> {
1465 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1466 w.put_bool((*self).long_distance);
1467 w.put_bool((*self).always_show);
1468 w.put_f64((*self).x);
1469 w.put_f64((*self).y);
1470 w.put_f64((*self).z);
1471 w.put_f32((*self).offset_x);
1472 w.put_f32((*self).offset_y);
1473 w.put_f32((*self).offset_z);
1474 w.put_f32((*self).velocity_offset);
1475 w.put_i32((*self).amount);
1476 (*self).particle.encode(w)?;
1477 Ok(())
1478 }
1479}
1480#[cfg(feature = "v26_2")]
1481#[cfg(feature = "testgen")]
1482impl<const V: i32> Generate for WorldParticles<V> {
1483 fn generate(g: &mut Gen) -> Self {
1484 {
1485 let v1 = g.bool();
1486 let v2 = g.bool();
1487 let v3 = g.f64();
1488 let v4 = g.f64();
1489 let v5 = g.f64();
1490 let v6 = g.f32();
1491 let v7 = g.f32();
1492 let v8 = g.f32();
1493 let v9 = g.f32();
1494 let v10 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1495 let v11 = <crate::defs::p776::types::Particle as Generate>::generate(g);
1496 Self {
1497 long_distance: v1,
1498 always_show: v2,
1499 x: v3,
1500 y: v4,
1501 z: v5,
1502 offset_x: v6,
1503 offset_y: v7,
1504 offset_z: v8,
1505 velocity_offset: v9,
1506 amount: v10,
1507 particle: v11,
1508 }
1509 }
1510 }
1511}
1512
1513#[cfg(feature = "v26_2")]
1514#[derive(Debug, Clone, PartialEq)]
1516pub struct Login<const V: i32> {
1517 pub entity_id: i32,
1519 pub is_hardcore: bool,
1521 pub world_names: Vec<ByteString>,
1523 pub max_players: i32,
1525 pub view_distance: i32,
1527 pub simulation_distance: i32,
1529 pub reduced_debug_info: bool,
1531 pub enable_respawn_screen: bool,
1533 pub do_limited_crafting: bool,
1535 pub world_state: crate::defs::p775::play::clientbound::SpawnInfo,
1537 pub online_mode: bool,
1539 pub enforces_secure_chat: bool,
1541}
1542#[cfg(feature = "v26_2")]
1543impl<const V: i32> Decode for Login<V> {
1544 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1545 Ok({
1546 let v1 = r.read_i32()?;
1547 let v2 = r.read_bool()?;
1548 let v3 = {
1549 let v4 = {
1550 let c = r.read_varint()?;
1551 r.check_count(i64::from(c), 1)?
1552 };
1553 let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
1554 for _ in 0..v4 {
1555 v5.push(r.read_string()?);
1556 }
1557 v5
1558 };
1559 let v6 = r.read_varint()?;
1560 let v7 = r.read_varint()?;
1561 let v8 = r.read_varint()?;
1562 let v9 = r.read_bool()?;
1563 let v10 = r.read_bool()?;
1564 let v11 = r.read_bool()?;
1565 let v12 = <crate::defs::p775::play::clientbound::SpawnInfo as Decode>::decode(r)?;
1566 let v13 = r.read_bool()?;
1567 let v14 = r.read_bool()?;
1568 Self {
1569 entity_id: v1,
1570 is_hardcore: v2,
1571 world_names: v3,
1572 max_players: v6,
1573 view_distance: v7,
1574 simulation_distance: v8,
1575 reduced_debug_info: v9,
1576 enable_respawn_screen: v10,
1577 do_limited_crafting: v11,
1578 world_state: v12,
1579 online_mode: v13,
1580 enforces_secure_chat: v14,
1581 }
1582 })
1583 }
1584}
1585#[cfg(feature = "v26_2")]
1586impl<const V: i32> Encode for Login<V> {
1587 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1588 w.put_i32((*self).entity_id);
1589 w.put_bool((*self).is_hardcore);
1590 w.put_len_varint((*self).world_names.len())?;
1591 for v1 in (*self).world_names.iter() {
1592 w.put_string(&(*v1))?;
1593 }
1594 w.put_varint((*self).max_players);
1595 w.put_varint((*self).view_distance);
1596 w.put_varint((*self).simulation_distance);
1597 w.put_bool((*self).reduced_debug_info);
1598 w.put_bool((*self).enable_respawn_screen);
1599 w.put_bool((*self).do_limited_crafting);
1600 (*self).world_state.encode(w)?;
1601 w.put_bool((*self).online_mode);
1602 w.put_bool((*self).enforces_secure_chat);
1603 Ok(())
1604 }
1605}
1606#[cfg(feature = "v26_2")]
1607#[cfg(feature = "testgen")]
1608impl<const V: i32> Generate for Login<V> {
1609 fn generate(g: &mut Gen) -> Self {
1610 {
1611 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1612 let v2 = g.bool();
1613 let v3 = {
1614 let v4 = g.count();
1615 let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
1616 for _ in 0..v4 {
1617 v5.push(g.string());
1618 }
1619 v5
1620 };
1621 let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1622 let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1623 let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1624 let v9 = g.bool();
1625 let v10 = g.bool();
1626 let v11 = g.bool();
1627 let v12 = <crate::defs::p775::play::clientbound::SpawnInfo as Generate>::generate(g);
1628 let v13 = g.bool();
1629 let v14 = g.bool();
1630 Self {
1631 entity_id: v1,
1632 is_hardcore: v2,
1633 world_names: v3,
1634 max_players: v6,
1635 view_distance: v7,
1636 simulation_distance: v8,
1637 reduced_debug_info: v9,
1638 enable_respawn_screen: v10,
1639 do_limited_crafting: v11,
1640 world_state: v12,
1641 online_mode: v13,
1642 enforces_secure_chat: v14,
1643 }
1644 }
1645 }
1646}
1647
1648#[cfg(feature = "v26_2")]
1649#[derive(Debug, Clone, PartialEq)]
1651pub struct TradeListTradesInputItem1 {
1652 pub item_id: i32,
1654 pub item_count: i32,
1656 pub components: Vec<crate::defs::p776::types::SlotComponent>,
1658}
1659
1660#[cfg(feature = "v26_2")]
1661#[derive(Debug, Clone, PartialEq)]
1663pub struct TradeListTradesInputItem2 {
1664 pub item_id: i32,
1666 pub item_count: i32,
1668 pub components: Vec<crate::defs::p776::types::SlotComponent>,
1670}
1671
1672#[cfg(feature = "v26_2")]
1673#[derive(Debug, Clone, PartialEq)]
1675pub struct TradeListTrades {
1676 pub input_item1: crate::defs::p776::play::clientbound::TradeListTradesInputItem1,
1678 pub output_item: crate::defs::p776::types::Slot,
1680 pub input_item2: Option<crate::defs::p776::play::clientbound::TradeListTradesInputItem2>,
1682 pub trade_disabled: bool,
1684 pub nb_trade_uses: i32,
1686 pub maximum_nb_trade_uses: i32,
1688 pub xp: i32,
1690 pub special_price: i32,
1692 pub price_multiplier: f32,
1694 pub demand: i32,
1696}
1697
1698#[cfg(feature = "v26_2")]
1699#[derive(Debug, Clone, PartialEq)]
1701pub struct TradeList<const V: i32> {
1702 pub window_id: i32,
1704 pub trades: Vec<crate::defs::p776::play::clientbound::TradeListTrades>,
1706 pub villager_level: i32,
1708 pub experience: i32,
1710 pub is_regular_villager: bool,
1712 pub can_restock: bool,
1714}
1715#[cfg(feature = "v26_2")]
1716impl<const V: i32> Decode for TradeList<V> {
1717 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1718 Ok({
1719 let v1 = r.read_varint()?;
1720 let v2 = {
1721 let v3 = {
1722 let c = r.read_varint()?;
1723 r.check_count(i64::from(c), 30)?
1724 };
1725 let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
1726 for _ in 0..v3 {
1727 v4.push({ let v5 = { let v6 = r.read_varint()?;let v7 = r.read_varint()?;let v8 = { let v9 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v9 { v10.push(<crate::defs::p776::types::SlotComponent as Decode>::decode(r)?); } v10 }; crate::defs::p776::play::clientbound::TradeListTradesInputItem1 { item_id: v6, item_count: v7, components: v8 } };let v11 = <crate::defs::p776::types::Slot as Decode>::decode(r)?;let v12 = if r.read_bool()? { Some({ let v13 = r.read_varint()?;let v14 = r.read_varint()?;let v15 = { let v16 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v16 { v17.push(<crate::defs::p776::types::SlotComponent as Decode>::decode(r)?); } v17 }; crate::defs::p776::play::clientbound::TradeListTradesInputItem2 { item_id: v13, item_count: v14, components: v15 } }) } else { None };let v18 = r.read_bool()?;let v19 = r.read_i32()?;let v20 = r.read_i32()?;let v21 = r.read_i32()?;let v22 = r.read_i32()?;let v23 = r.read_f32()?;let v24 = r.read_i32()?; crate::defs::p776::play::clientbound::TradeListTrades { input_item1: v5, output_item: v11, input_item2: v12, trade_disabled: v18, nb_trade_uses: v19, maximum_nb_trade_uses: v20, xp: v21, special_price: v22, price_multiplier: v23, demand: v24 } });
1728 }
1729 v4
1730 };
1731 let v25 = r.read_varint()?;
1732 let v26 = r.read_varint()?;
1733 let v27 = r.read_bool()?;
1734 let v28 = r.read_bool()?;
1735 Self {
1736 window_id: v1,
1737 trades: v2,
1738 villager_level: v25,
1739 experience: v26,
1740 is_regular_villager: v27,
1741 can_restock: v28,
1742 }
1743 })
1744 }
1745}
1746#[cfg(feature = "v26_2")]
1747impl<const V: i32> Encode for TradeList<V> {
1748 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1749 w.put_varint((*self).window_id);
1750 w.put_len_varint((*self).trades.len())?;
1751 for v1 in (*self).trades.iter() {
1752 w.put_varint((*v1).input_item1.item_id);
1753 w.put_varint((*v1).input_item1.item_count);
1754 w.put_len_varint((*v1).input_item1.components.len())?;
1755 for v2 in (*v1).input_item1.components.iter() {
1756 (*v2).encode(w)?;
1757 }
1758 (*v1).output_item.encode(w)?;
1759 match &(*v1).input_item2 {
1760 Some(v3) => {
1761 w.put_u8(1);
1762 w.put_varint((*v3).item_id);
1763 w.put_varint((*v3).item_count);
1764 w.put_len_varint((*v3).components.len())?;
1765 for v4 in (*v3).components.iter() {
1766 (*v4).encode(w)?;
1767 }
1768 }
1769 None => w.put_u8(0),
1770 }
1771 w.put_bool((*v1).trade_disabled);
1772 w.put_i32((*v1).nb_trade_uses);
1773 w.put_i32((*v1).maximum_nb_trade_uses);
1774 w.put_i32((*v1).xp);
1775 w.put_i32((*v1).special_price);
1776 w.put_f32((*v1).price_multiplier);
1777 w.put_i32((*v1).demand);
1778 }
1779 w.put_varint((*self).villager_level);
1780 w.put_varint((*self).experience);
1781 w.put_bool((*self).is_regular_villager);
1782 w.put_bool((*self).can_restock);
1783 Ok(())
1784 }
1785}
1786#[cfg(feature = "v26_2")]
1787#[cfg(feature = "testgen")]
1788impl<const V: i32> Generate for TradeList<V> {
1789 fn generate(g: &mut Gen) -> Self {
1790 {
1791 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1792 let v2 = {
1793 let v3 = g.count();
1794 let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
1795 for _ in 0..v3 {
1796 v4.push({ let v5 = { let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v8 = { let v9 = g.count(); let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v9 { v10.push(<crate::defs::p776::types::SlotComponent as Generate>::generate(g)); } v10 }; crate::defs::p776::play::clientbound::TradeListTradesInputItem1 { item_id: v6, item_count: v7, components: v8 } };let v11 = <crate::defs::p776::types::Slot as Generate>::generate(g);let v12 = if g.bool() { Some({ let v13 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v14 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v15 = { let v16 = g.count(); let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v16 { v17.push(<crate::defs::p776::types::SlotComponent as Generate>::generate(g)); } v17 }; crate::defs::p776::play::clientbound::TradeListTradesInputItem2 { item_id: v13, item_count: v14, components: v15 } }) } else { None };let v18 = g.bool();let v19 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v20 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v21 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v22 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v23 = g.f32();let v24 = (g.int_in(-2147483648, 2147483647, &[]) as i32); crate::defs::p776::play::clientbound::TradeListTrades { input_item1: v5, output_item: v11, input_item2: v12, trade_disabled: v18, nb_trade_uses: v19, maximum_nb_trade_uses: v20, xp: v21, special_price: v22, price_multiplier: v23, demand: v24 } });
1797 }
1798 v4
1799 };
1800 let v25 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1801 let v26 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1802 let v27 = g.bool();
1803 let v28 = g.bool();
1804 Self {
1805 window_id: v1,
1806 trades: v2,
1807 villager_level: v25,
1808 experience: v26,
1809 is_regular_villager: v27,
1810 can_restock: v28,
1811 }
1812 }
1813 }
1814}
1815
1816#[cfg(feature = "v26_2")]
1817#[derive(Debug, Clone, PartialEq)]
1819pub struct CraftRecipeResponse<const V: i32> {
1820 pub window_id: i32,
1822 pub recipe_display: crate::defs::p776::play::clientbound::RecipeDisplay,
1824}
1825#[cfg(feature = "v26_2")]
1826impl<const V: i32> Decode for CraftRecipeResponse<V> {
1827 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1828 Ok({
1829 let v1 = r.read_varint()?;
1830 let v2 = <crate::defs::p776::play::clientbound::RecipeDisplay as Decode>::decode(r)?;
1831 Self {
1832 window_id: v1,
1833 recipe_display: v2,
1834 }
1835 })
1836 }
1837}
1838#[cfg(feature = "v26_2")]
1839impl<const V: i32> Encode for CraftRecipeResponse<V> {
1840 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1841 w.put_varint((*self).window_id);
1842 (*self).recipe_display.encode(w)?;
1843 Ok(())
1844 }
1845}
1846#[cfg(feature = "v26_2")]
1847#[cfg(feature = "testgen")]
1848impl<const V: i32> Generate for CraftRecipeResponse<V> {
1849 fn generate(g: &mut Gen) -> Self {
1850 {
1851 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1852 let v2 = <crate::defs::p776::play::clientbound::RecipeDisplay as Generate>::generate(g);
1853 Self {
1854 window_id: v1,
1855 recipe_display: v2,
1856 }
1857 }
1858 }
1859}
1860
1861#[cfg(feature = "v26_2")]
1862#[derive(Debug, Clone, PartialEq)]
1864pub struct RecipeBookAddEntriesRecipe {
1865 pub display_id: i32,
1867 pub display: crate::defs::p776::play::clientbound::RecipeDisplay,
1869 pub group: i32,
1871 pub category: crate::defs::p775::play::clientbound::RecipeBookAddEntriesRecipeCategory,
1873 pub crafting_requirements: Option<Vec<HolderSet>>,
1875}
1876
1877#[cfg(feature = "v26_2")]
1878#[derive(Debug, Clone, PartialEq)]
1880pub struct RecipeBookAddEntries {
1881 pub recipe: crate::defs::p776::play::clientbound::RecipeBookAddEntriesRecipe,
1883 pub flags: crate::defs::p775::play::clientbound::RecipeBookAddEntriesFlags,
1885}
1886
1887#[cfg(feature = "v26_2")]
1888#[derive(Debug, Clone, PartialEq)]
1890pub struct RecipeBookAdd<const V: i32> {
1891 pub entries: Vec<crate::defs::p776::play::clientbound::RecipeBookAddEntries>,
1893 pub replace: bool,
1895}
1896#[cfg(feature = "v26_2")]
1897impl<const V: i32> Decode for RecipeBookAdd<V> {
1898 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1899 Ok({
1900 let v1 = {
1901 let v2 = {
1902 let c = r.read_varint()?;
1903 r.check_count(i64::from(c), 6)?
1904 };
1905 let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
1906 for _ in 0..v2 {
1907 v3.push({ let v4 = { let v5 = r.read_varint()?;let v6 = <crate::defs::p776::play::clientbound::RecipeDisplay as Decode>::decode(r)?;let v7 = r.read_varint()?;let v8 = crate::defs::p775::play::clientbound::RecipeBookAddEntriesRecipeCategory(r.read_varint()?);let v9 = if r.read_bool()? { Some({ let v10 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v11 = Vec::with_capacity(v10.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v10 { v11.push(<HolderSet as Decode>::decode(r)?); } v11 }) } else { None }; crate::defs::p776::play::clientbound::RecipeBookAddEntriesRecipe { display_id: v5, display: v6, group: v7, category: v8, crafting_requirements: v9 } };let v12 = crate::defs::p775::play::clientbound::RecipeBookAddEntriesFlags(r.read_u8()?); crate::defs::p776::play::clientbound::RecipeBookAddEntries { recipe: v4, flags: v12 } });
1908 }
1909 v3
1910 };
1911 let v13 = r.read_bool()?;
1912 Self {
1913 entries: v1,
1914 replace: v13,
1915 }
1916 })
1917 }
1918}
1919#[cfg(feature = "v26_2")]
1920impl<const V: i32> Encode for RecipeBookAdd<V> {
1921 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1922 w.put_len_varint((*self).entries.len())?;
1923 for v1 in (*self).entries.iter() {
1924 w.put_varint((*v1).recipe.display_id);
1925 (*v1).recipe.display.encode(w)?;
1926 w.put_varint((*v1).recipe.group);
1927 w.put_varint((*v1).recipe.category.0);
1928 match &(*v1).recipe.crafting_requirements {
1929 Some(v2) => {
1930 w.put_u8(1);
1931 w.put_len_varint((*v2).len())?;
1932 for v3 in (*v2).iter() {
1933 (*v3).encode(w)?;
1934 }
1935 }
1936 None => w.put_u8(0),
1937 }
1938 w.put_u8((*v1).flags.0);
1939 }
1940 w.put_bool((*self).replace);
1941 Ok(())
1942 }
1943}
1944#[cfg(feature = "v26_2")]
1945#[cfg(feature = "testgen")]
1946impl<const V: i32> Generate for RecipeBookAdd<V> {
1947 fn generate(g: &mut Gen) -> Self {
1948 {
1949 let v1 = {
1950 let v2 = g.count();
1951 let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
1952 for _ in 0..v2 {
1953 v3.push({ let v4 = { let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v6 = <crate::defs::p776::play::clientbound::RecipeDisplay as Generate>::generate(g);let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v8 = crate::defs::p775::play::clientbound::RecipeBookAddEntriesRecipeCategory(g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) as i32);let v9 = if g.bool() { Some({ let v10 = g.count(); let mut v11 = Vec::with_capacity(v10.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v10 { v11.push(<HolderSet as Generate>::generate(g)); } v11 }) } else { None }; crate::defs::p776::play::clientbound::RecipeBookAddEntriesRecipe { display_id: v5, display: v6, group: v7, category: v8, crafting_requirements: v9 } };let v12 = crate::defs::p775::play::clientbound::RecipeBookAddEntriesFlags(g.int_in(0, 255, &[]) as u8); crate::defs::p776::play::clientbound::RecipeBookAddEntries { recipe: v4, flags: v12 } });
1954 }
1955 v3
1956 };
1957 let v13 = g.bool();
1958 Self {
1959 entries: v1,
1960 replace: v13,
1961 }
1962 }
1963 }
1964}
1965
1966#[cfg(feature = "v26_2")]
1967#[derive(Debug, Clone, PartialEq)]
1969pub struct SetCursorItem<const V: i32> {
1970 pub contents: crate::defs::p776::types::Slot,
1972}
1973#[cfg(feature = "v26_2")]
1974impl<const V: i32> Decode for SetCursorItem<V> {
1975 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1976 Ok({
1977 let v1 = <crate::defs::p776::types::Slot as Decode>::decode(r)?;
1978 Self { contents: v1 }
1979 })
1980 }
1981}
1982#[cfg(feature = "v26_2")]
1983impl<const V: i32> Encode for SetCursorItem<V> {
1984 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1985 (*self).contents.encode(w)?;
1986 Ok(())
1987 }
1988}
1989#[cfg(feature = "v26_2")]
1990#[cfg(feature = "testgen")]
1991impl<const V: i32> Generate for SetCursorItem<V> {
1992 fn generate(g: &mut Gen) -> Self {
1993 {
1994 let v1 = <crate::defs::p776::types::Slot as Generate>::generate(g);
1995 Self { contents: v1 }
1996 }
1997 }
1998}
1999
2000#[cfg(feature = "v26_2")]
2001#[derive(Debug, Clone, PartialEq)]
2003pub struct EntityMetadata<const V: i32> {
2004 pub entity_id: i32,
2006 pub metadata: Vec<crate::defs::p776::types::EntityMetadataEntry>,
2008}
2009#[cfg(feature = "v26_2")]
2010impl<const V: i32> Decode for EntityMetadata<V> {
2011 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2012 Ok({
2013 let v1 = r.read_varint()?;
2014 let v2 = {
2015 let mut v3 = Vec::new();
2016 loop {
2017 if r.peek_u8()? == 255 {
2018 r.skip(1)?;
2019 break;
2020 }
2021 v3.push(<crate::defs::p776::types::EntityMetadataEntry as Decode>::decode(r)?);
2022 }
2023 v3
2024 };
2025 Self {
2026 entity_id: v1,
2027 metadata: v2,
2028 }
2029 })
2030 }
2031}
2032#[cfg(feature = "v26_2")]
2033impl<const V: i32> Encode for EntityMetadata<V> {
2034 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2035 w.put_varint((*self).entity_id);
2036 for v1 in (*self).metadata.iter() {
2037 let v2 = w.len();
2038 (*v1).encode(w)?;
2039 if w.get(v2) == Some(&255) {
2040 return Err(EncodeError::OutOfRange(
2041 "play.clientbound.entity_metadata.metadata",
2042 ));
2043 }
2044 }
2045 w.put_u8(255);
2046 Ok(())
2047 }
2048}
2049#[cfg(feature = "v26_2")]
2050#[cfg(feature = "testgen")]
2051impl<const V: i32> Generate for EntityMetadata<V> {
2052 fn generate(g: &mut Gen) -> Self {
2053 {
2054 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2055 let v2 = {
2056 let n = g.count();
2057 let mut v3 = Vec::with_capacity(n);
2058 for _ in 0..n {
2059 v3.push(loop {
2060 let v4 =
2061 <crate::defs::p776::types::EntityMetadataEntry as Generate>::generate(
2062 g,
2063 );
2064 if crate::testgen::first_byte_ok(
2065 |w: &mut BytesMut| -> EncodeResult {
2066 v4.encode(w)?;
2067 Ok(())
2068 },
2069 |b| b != 255,
2070 ) {
2071 break v4;
2072 }
2073 });
2074 }
2075 v3
2076 };
2077 Self {
2078 entity_id: v1,
2079 metadata: v2,
2080 }
2081 }
2082 }
2083}
2084
2085#[cfg(feature = "v26_2")]
2086#[derive(Debug, Clone, PartialEq)]
2088pub struct EntityEquipmentEquipments {
2089 pub slot: i8,
2091 pub item: crate::defs::p776::types::Slot,
2093}
2094
2095#[cfg(feature = "v26_2")]
2096#[derive(Debug, Clone, PartialEq)]
2098pub struct EntityEquipment<const V: i32> {
2099 pub entity_id: i32,
2101 pub equipments: Vec<crate::defs::p776::play::clientbound::EntityEquipmentEquipments>,
2103}
2104#[cfg(feature = "v26_2")]
2105impl<const V: i32> Decode for EntityEquipment<V> {
2106 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2107 Ok({
2108 let v1 = r.read_varint()?;
2109 let v2 = {
2110 let mut v3 = Vec::new();
2111 loop {
2112 let v4 = r.read_u8()?;
2113 v3.push({
2114 let v5 = ((v4 & 0x7f) as i8);
2115 let v6 = <crate::defs::p776::types::Slot as Decode>::decode(r)?;
2116 crate::defs::p776::play::clientbound::EntityEquipmentEquipments {
2117 slot: v5,
2118 item: v6,
2119 }
2120 });
2121 if v4 & 0x80 == 0 {
2122 break;
2123 }
2124 }
2125 v3
2126 };
2127 Self {
2128 entity_id: v1,
2129 equipments: v2,
2130 }
2131 })
2132 }
2133}
2134#[cfg(feature = "v26_2")]
2135impl<const V: i32> Encode for EntityEquipment<V> {
2136 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2137 w.put_varint((*self).entity_id);
2138 if (*self).equipments.is_empty() {
2139 return Err(EncodeError::CountMismatch {
2140 field: "play.clientbound.entity_equipment.equipments",
2141 expected: 1,
2142 actual: 0,
2143 });
2144 }
2145 for (v2, v1) in (*self).equipments.iter().enumerate() {
2146 let v3 = w.len();
2147 w.put_i8((*v1).slot);
2148 (*v1).item.encode(w)?;
2149 match w.get_mut(v3) {
2150 Some(b) if *b & 0x80 == 0 => {
2151 if v2 + 1 < (*self).equipments.len() {
2152 *b |= 0x80;
2153 }
2154 }
2155 _ => {
2156 return Err(EncodeError::OutOfRange(
2157 "play.clientbound.entity_equipment.equipments",
2158 ));
2159 }
2160 }
2161 }
2162 Ok(())
2163 }
2164}
2165#[cfg(feature = "v26_2")]
2166#[cfg(feature = "testgen")]
2167impl<const V: i32> Generate for EntityEquipment<V> {
2168 fn generate(g: &mut Gen) -> Self {
2169 {
2170 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2171 let v2 = {
2172 let n = 1 + g.count();
2173 let mut v3 = Vec::with_capacity(n);
2174 for _ in 0..n {
2175 v3.push(loop {
2176 let v4 = {
2177 let v5 = (g.int_in(-128, 127, &[]) as i8);
2178 let v6 = <crate::defs::p776::types::Slot as Generate>::generate(g);
2179 crate::defs::p776::play::clientbound::EntityEquipmentEquipments {
2180 slot: v5,
2181 item: v6,
2182 }
2183 };
2184 if crate::testgen::first_byte_ok(
2185 |w: &mut BytesMut| -> EncodeResult {
2186 w.put_i8(v4.slot);
2187 v4.item.encode(w)?;
2188 Ok(())
2189 },
2190 |b| b & 0x80 == 0,
2191 ) {
2192 break v4;
2193 }
2194 });
2195 }
2196 v3
2197 };
2198 Self {
2199 entity_id: v1,
2200 equipments: v2,
2201 }
2202 }
2203 }
2204}
2205
2206#[cfg(feature = "v26_2")]
2207#[derive(Debug, Clone, PartialEq)]
2209pub struct SetPlayerInventory<const V: i32> {
2210 pub slot_id: i32,
2212 pub contents: crate::defs::p776::types::Slot,
2214}
2215#[cfg(feature = "v26_2")]
2216impl<const V: i32> Decode for SetPlayerInventory<V> {
2217 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2218 Ok({
2219 let v1 = r.read_varint()?;
2220 let v2 = <crate::defs::p776::types::Slot as Decode>::decode(r)?;
2221 Self {
2222 slot_id: v1,
2223 contents: v2,
2224 }
2225 })
2226 }
2227}
2228#[cfg(feature = "v26_2")]
2229impl<const V: i32> Encode for SetPlayerInventory<V> {
2230 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2231 w.put_varint((*self).slot_id);
2232 (*self).contents.encode(w)?;
2233 Ok(())
2234 }
2235}
2236#[cfg(feature = "v26_2")]
2237#[cfg(feature = "testgen")]
2238impl<const V: i32> Generate for SetPlayerInventory<V> {
2239 fn generate(g: &mut Gen) -> Self {
2240 {
2241 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2242 let v2 = <crate::defs::p776::types::Slot as Generate>::generate(g);
2243 Self {
2244 slot_id: v1,
2245 contents: v2,
2246 }
2247 }
2248 }
2249}
2250
2251#[cfg(feature = "v26_2")]
2252#[derive(Debug, Clone, PartialEq)]
2254pub struct TeamsBodyAdd {
2255 pub name: AnonNbt,
2257 pub prefix: AnonNbt,
2259 pub suffix: AnonNbt,
2261 pub name_tag_visibility: crate::defs::p775::play::clientbound::TeamsBodyAddNameTagVisibility,
2263 pub collision_rule: crate::defs::p775::play::clientbound::TeamsBodyAddCollisionRule,
2265 pub color: Option<i32>,
2267 pub flags: crate::defs::p775::play::clientbound::TeamsBodyAddFlags,
2269}
2270
2271#[cfg(feature = "v26_2")]
2272#[derive(Debug, Clone, PartialEq)]
2274pub struct Teams<const V: i32> {
2275 pub team: ByteString,
2277 pub mode: crate::defs::p775::play::clientbound::TeamsMode,
2279 pub body: Option<crate::defs::p776::play::clientbound::TeamsBodyAdd>,
2281 pub players: Option<Vec<ByteString>>,
2283}
2284#[cfg(feature = "v26_2")]
2285impl<const V: i32> Decode for Teams<V> {
2286 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2287 Ok({
2288 let v1 = r.read_string()?;
2289 let v2 = crate::defs::p775::play::clientbound::TeamsMode(r.read_i8()?);
2290 let v3 = if (v2.0 == 0) || (v2.0 == 2) {
2291 Some({
2292 let v4 = AnonNbt::read(r)?;
2293 let v5 = AnonNbt::read(r)?;
2294 let v6 = AnonNbt::read(r)?;
2295 let v7 = crate::defs::p775::play::clientbound::TeamsBodyAddNameTagVisibility(
2296 r.read_varint()?,
2297 );
2298 let v8 = crate::defs::p775::play::clientbound::TeamsBodyAddCollisionRule(
2299 r.read_varint()?,
2300 );
2301 let v9 = if r.read_bool()? {
2302 Some(r.read_varint()?)
2303 } else {
2304 None
2305 };
2306 let v10 = crate::defs::p775::play::clientbound::TeamsBodyAddFlags(r.read_u8()?);
2307 crate::defs::p776::play::clientbound::TeamsBodyAdd {
2308 name: v4,
2309 prefix: v5,
2310 suffix: v6,
2311 name_tag_visibility: v7,
2312 collision_rule: v8,
2313 color: v9,
2314 flags: v10,
2315 }
2316 })
2317 } else {
2318 None
2319 };
2320 let v11 = if (v2.0 == 0) || (v2.0 == 3) || (v2.0 == 4) {
2321 Some({
2322 let v12 = {
2323 let c = r.read_varint()?;
2324 r.check_count(i64::from(c), 1)?
2325 };
2326 let mut v13 = Vec::with_capacity(v12.min(crate::codec::PREALLOC_LIMIT));
2327 for _ in 0..v12 {
2328 v13.push(r.read_string()?);
2329 }
2330 v13
2331 })
2332 } else {
2333 None
2334 };
2335 Self {
2336 team: v1,
2337 mode: v2,
2338 body: v3,
2339 players: v11,
2340 }
2341 })
2342 }
2343}
2344#[cfg(feature = "v26_2")]
2345impl<const V: i32> Encode for Teams<V> {
2346 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2347 w.put_string(&(*self).team)?;
2348 w.put_i8((*self).mode.0);
2349 match (
2350 &(*self).body,
2351 ((*self).mode.0 == 0) || ((*self).mode.0 == 2),
2352 ) {
2353 (Some(v1), true) => {
2354 (*v1).name.write(w);
2355 (*v1).prefix.write(w);
2356 (*v1).suffix.write(w);
2357 w.put_varint((*v1).name_tag_visibility.0);
2358 w.put_varint((*v1).collision_rule.0);
2359 match &(*v1).color {
2360 Some(v2) => {
2361 w.put_u8(1);
2362 w.put_varint((*v2));
2363 }
2364 None => w.put_u8(0),
2365 }
2366 w.put_u8((*v1).flags.0);
2367 }
2368 (None, false) => {}
2369 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.body")),
2370 }
2371 match (
2372 &(*self).players,
2373 ((*self).mode.0 == 0) || ((*self).mode.0 == 3) || ((*self).mode.0 == 4),
2374 ) {
2375 (Some(v3), true) => {
2376 w.put_len_varint((*v3).len())?;
2377 for v4 in (*v3).iter() {
2378 w.put_string(&(*v4))?;
2379 }
2380 }
2381 (None, false) => {}
2382 _ => {
2383 return Err(EncodeError::SwitchMismatch(
2384 "play.clientbound.teams.players",
2385 ));
2386 }
2387 }
2388 Ok(())
2389 }
2390}
2391#[cfg(feature = "v26_2")]
2392#[cfg(feature = "testgen")]
2393impl<const V: i32> Generate for Teams<V> {
2394 fn generate(g: &mut Gen) -> Self {
2395 {
2396 let v1 = g.string();
2397 let v2 = crate::defs::p775::play::clientbound::TeamsMode(g.int_in(
2398 -128,
2399 127,
2400 &[0, 1, 2, 3, 4],
2401 ) as i8);
2402 let v3 =
2403 if (v2.0 == 0) || (v2.0 == 2) {
2404 Some({
2405 let v4 = g.anon_nbt();
2406 let v5 = g.anon_nbt();
2407 let v6 = g.anon_nbt();
2408 let v7 =
2409 crate::defs::p775::play::clientbound::TeamsBodyAddNameTagVisibility(
2410 g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3]) as i32,
2411 );
2412 let v8 = crate::defs::p775::play::clientbound::TeamsBodyAddCollisionRule(
2413 g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3]) as i32,
2414 );
2415 let v9 = if g.bool() {
2416 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
2417 } else {
2418 None
2419 };
2420 let v10 = crate::defs::p775::play::clientbound::TeamsBodyAddFlags(
2421 g.int_in(0, 255, &[]) as u8,
2422 );
2423 crate::defs::p776::play::clientbound::TeamsBodyAdd {
2424 name: v4,
2425 prefix: v5,
2426 suffix: v6,
2427 name_tag_visibility: v7,
2428 collision_rule: v8,
2429 color: v9,
2430 flags: v10,
2431 }
2432 })
2433 } else {
2434 None
2435 };
2436 let v11 = if (v2.0 == 0) || (v2.0 == 3) || (v2.0 == 4) {
2437 Some({
2438 let v12 = g.count();
2439 let mut v13 = Vec::with_capacity(v12.min(crate::codec::PREALLOC_LIMIT));
2440 for _ in 0..v12 {
2441 v13.push(g.string());
2442 }
2443 v13
2444 })
2445 } else {
2446 None
2447 };
2448 Self {
2449 team: v1,
2450 mode: v2,
2451 body: v3,
2452 players: v11,
2453 }
2454 }
2455 }
2456}
2457
2458#[cfg(feature = "v26_2")]
2459#[derive(Debug, Clone, PartialEq)]
2461pub struct AdvancementsAdvancementMappingValueDisplayData {
2462 pub title: AnonNbt,
2464 pub description: AnonNbt,
2466 pub icon: crate::defs::p776::types::ItemStackTemplate,
2468 pub frame_type: i32,
2470 pub flags:
2472 crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags,
2473 pub background_texture: Option<ByteString>,
2475 pub x_cord: f32,
2477 pub y_cord: f32,
2479}
2480
2481#[cfg(feature = "v26_2")]
2482#[derive(Debug, Clone, PartialEq)]
2484pub struct AdvancementsAdvancementMappingValue {
2485 pub parent_id: Option<ByteString>,
2487 pub display_data: Option<
2489 crate::defs::p776::play::clientbound::AdvancementsAdvancementMappingValueDisplayData,
2490 >,
2491 pub requirements: Vec<Vec<ByteString>>,
2493 pub sends_telemtry_data: bool,
2495}
2496
2497#[cfg(feature = "v26_2")]
2498#[derive(Debug, Clone, PartialEq)]
2500pub struct AdvancementsAdvancementMapping {
2501 pub key: ByteString,
2503 pub value: crate::defs::p776::play::clientbound::AdvancementsAdvancementMappingValue,
2505}
2506
2507#[cfg(feature = "v26_2")]
2508#[derive(Debug, Clone, PartialEq)]
2510pub struct Advancements<const V: i32> {
2511 pub reset: bool,
2513 pub advancement_mapping:
2515 Vec<crate::defs::p776::play::clientbound::AdvancementsAdvancementMapping>,
2516 pub identifiers: Vec<ByteString>,
2518 pub progress_mapping: Vec<crate::defs::p340::play::clientbound::AdvancementsProgressMapping>,
2520 pub show_advancements: bool,
2522}
2523#[cfg(feature = "v26_2")]
2524impl<const V: i32> Decode for Advancements<V> {
2525 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2526 Ok({
2527 let v1 = r.read_bool()?;
2528 let v2 = {
2529 let v3 = {
2530 let c = r.read_varint()?;
2531 r.check_count(i64::from(c), 5)?
2532 };
2533 let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
2534 for _ in 0..v3 {
2535 v4.push({ let v5 = r.read_string()?;let v6 = { let v7 = if r.read_bool()? { Some(r.read_string()?) } else { None };let v8 = if r.read_bool()? { Some({ let v9 = AnonNbt::read(r)?;let v10 = AnonNbt::read(r)?;let v11 = <crate::defs::p776::types::ItemStackTemplate as Decode>::decode(r)?;let v12 = r.read_varint()?;let v13 = { let v14 = u64::from(r.read_i32()? as u32); crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags { unused: (((v14 >> 3) & 0x1fffffff) as u32), hidden: (((v14 >> 2) & 0x1) as u8), show_toast: (((v14 >> 1) & 0x1) as u8), has_background_texture: (((v14 >> 0) & 0x1) as u8) } };let v15 = if (v13.has_background_texture == 1) { Some(r.read_string()?) } else { None };let v16 = r.read_f32()?;let v17 = r.read_f32()?; crate::defs::p776::play::clientbound::AdvancementsAdvancementMappingValueDisplayData { title: v9, description: v10, icon: v11, frame_type: v12, flags: v13, background_texture: v15, x_cord: v16, y_cord: v17 } }) } else { None };let v18 = { let v19 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v20 = Vec::with_capacity(v19.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v19 { v20.push({ let v21 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v22 = Vec::with_capacity(v21.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v21 { v22.push(r.read_string()?); } v22 }); } v20 };let v23 = r.read_bool()?; crate::defs::p776::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, requirements: v18, sends_telemtry_data: v23 } }; crate::defs::p776::play::clientbound::AdvancementsAdvancementMapping { key: v5, value: v6 } });
2536 }
2537 v4
2538 };
2539 let v24 = {
2540 let v25 = {
2541 let c = r.read_varint()?;
2542 r.check_count(i64::from(c), 1)?
2543 };
2544 let mut v26 = Vec::with_capacity(v25.min(crate::codec::PREALLOC_LIMIT));
2545 for _ in 0..v25 {
2546 v26.push(r.read_string()?);
2547 }
2548 v26
2549 };
2550 let v27 = {
2551 let v28 = {
2552 let c = r.read_varint()?;
2553 r.check_count(i64::from(c), 2)?
2554 };
2555 let mut v29 = Vec::with_capacity(v28.min(crate::codec::PREALLOC_LIMIT));
2556 for _ in 0..v28 {
2557 v29.push({ let v30 = r.read_string()?;let v31 = { let v32 = { let c = r.read_varint()?; r.check_count(i64::from(c), 2)? }; let mut v33 = Vec::with_capacity(v32.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v32 { v33.push({ let v34 = r.read_string()?;let v35 = if r.read_bool()? { Some(r.read_i64()?) } else { None }; crate::defs::p340::play::clientbound::AdvancementsProgressMappingValue { criterion_identifier: v34, criterion_progress: v35 } }); } v33 }; crate::defs::p340::play::clientbound::AdvancementsProgressMapping { key: v30, value: v31 } });
2558 }
2559 v29
2560 };
2561 let v36 = r.read_bool()?;
2562 Self {
2563 reset: v1,
2564 advancement_mapping: v2,
2565 identifiers: v24,
2566 progress_mapping: v27,
2567 show_advancements: v36,
2568 }
2569 })
2570 }
2571}
2572#[cfg(feature = "v26_2")]
2573impl<const V: i32> Encode for Advancements<V> {
2574 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2575 w.put_bool((*self).reset);
2576 w.put_len_varint((*self).advancement_mapping.len())?;
2577 for v1 in (*self).advancement_mapping.iter() {
2578 w.put_string(&(*v1).key)?;
2579 match &(*v1).value.parent_id {
2580 Some(v2) => {
2581 w.put_u8(1);
2582 w.put_string(&(*v2))?;
2583 }
2584 None => w.put_u8(0),
2585 }
2586 match &(*v1).value.display_data {
2587 Some(v3) => {
2588 w.put_u8(1);
2589 (*v3).title.write(w);
2590 (*v3).description.write(w);
2591 (*v3).icon.encode(w)?;
2592 w.put_varint((*v3).frame_type);
2593 {
2594 let mut bits: u64 = 0;
2595 {
2596 let x = i128::from((*v3).flags.unused);
2597 if x < 0 || x > 536870911 {
2598 return Err(EncodeError::OutOfRange("unused"));
2599 }
2600 bits = (bits << 29) | ((x as u64) & 0x1fffffff);
2601 }
2602 {
2603 let x = i128::from((*v3).flags.hidden);
2604 if x < 0 || x > 1 {
2605 return Err(EncodeError::OutOfRange("hidden"));
2606 }
2607 bits = (bits << 1) | ((x as u64) & 0x1);
2608 }
2609 {
2610 let x = i128::from((*v3).flags.show_toast);
2611 if x < 0 || x > 1 {
2612 return Err(EncodeError::OutOfRange("show_toast"));
2613 }
2614 bits = (bits << 1) | ((x as u64) & 0x1);
2615 }
2616 {
2617 let x = i128::from((*v3).flags.has_background_texture);
2618 if x < 0 || x > 1 {
2619 return Err(EncodeError::OutOfRange("has_background_texture"));
2620 }
2621 bits = (bits << 1) | ((x as u64) & 0x1);
2622 }
2623 w.put_u32(bits as u32);
2624 }
2625 match (
2626 &(*v3).background_texture,
2627 ((*v3).flags.has_background_texture == 1),
2628 ) {
2629 (Some(v4), true) => {
2630 w.put_string(&(*v4))?;
2631 }
2632 (None, false) => {}
2633 _ => {
2634 return Err(EncodeError::SwitchMismatch(
2635 "play.clientbound.advancements.advancementMapping.value.displayData.backgroundTexture",
2636 ));
2637 }
2638 }
2639 w.put_f32((*v3).x_cord);
2640 w.put_f32((*v3).y_cord);
2641 }
2642 None => w.put_u8(0),
2643 }
2644 w.put_len_varint((*v1).value.requirements.len())?;
2645 for v5 in (*v1).value.requirements.iter() {
2646 w.put_len_varint((*v5).len())?;
2647 for v6 in (*v5).iter() {
2648 w.put_string(&(*v6))?;
2649 }
2650 }
2651 w.put_bool((*v1).value.sends_telemtry_data);
2652 }
2653 w.put_len_varint((*self).identifiers.len())?;
2654 for v7 in (*self).identifiers.iter() {
2655 w.put_string(&(*v7))?;
2656 }
2657 w.put_len_varint((*self).progress_mapping.len())?;
2658 for v8 in (*self).progress_mapping.iter() {
2659 w.put_string(&(*v8).key)?;
2660 w.put_len_varint((*v8).value.len())?;
2661 for v9 in (*v8).value.iter() {
2662 w.put_string(&(*v9).criterion_identifier)?;
2663 match &(*v9).criterion_progress {
2664 Some(v10) => {
2665 w.put_u8(1);
2666 w.put_i64((*v10));
2667 }
2668 None => w.put_u8(0),
2669 }
2670 }
2671 }
2672 w.put_bool((*self).show_advancements);
2673 Ok(())
2674 }
2675}
2676#[cfg(feature = "v26_2")]
2677#[cfg(feature = "testgen")]
2678impl<const V: i32> Generate for Advancements<V> {
2679 fn generate(g: &mut Gen) -> Self {
2680 {
2681 let v1 = g.bool();
2682 let v2 = {
2683 let v3 = g.count();
2684 let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
2685 for _ in 0..v3 {
2686 v4.push({ let v5 = g.string();let v6 = { let v7 = if g.bool() { Some(g.string()) } else { None };let v8 = if g.bool() { Some({ let v9 = g.anon_nbt();let v10 = g.anon_nbt();let v11 = <crate::defs::p776::types::ItemStackTemplate as Generate>::generate(g);let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v13 = { crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags { unused: (g.int_in(0, 536870911, &[]) as u32), hidden: (g.int_in(0, 1, &[]) as u8), show_toast: (g.int_in(0, 1, &[]) as u8), has_background_texture: (g.int_in(0, 1, &[1]) as u8) } };let v15 = if (v13.has_background_texture == 1) { Some(g.string()) } else { None };let v16 = g.f32();let v17 = g.f32(); crate::defs::p776::play::clientbound::AdvancementsAdvancementMappingValueDisplayData { title: v9, description: v10, icon: v11, frame_type: v12, flags: v13, background_texture: v15, x_cord: v16, y_cord: v17 } }) } else { None };let v18 = { let v19 = g.count(); let mut v20 = Vec::with_capacity(v19.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v19 { v20.push({ let v21 = g.count(); let mut v22 = Vec::with_capacity(v21.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v21 { v22.push(g.string()); } v22 }); } v20 };let v23 = g.bool(); crate::defs::p776::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, requirements: v18, sends_telemtry_data: v23 } }; crate::defs::p776::play::clientbound::AdvancementsAdvancementMapping { key: v5, value: v6 } });
2687 }
2688 v4
2689 };
2690 let v24 = {
2691 let v25 = g.count();
2692 let mut v26 = Vec::with_capacity(v25.min(crate::codec::PREALLOC_LIMIT));
2693 for _ in 0..v25 {
2694 v26.push(g.string());
2695 }
2696 v26
2697 };
2698 let v27 = {
2699 let v28 = g.count();
2700 let mut v29 = Vec::with_capacity(v28.min(crate::codec::PREALLOC_LIMIT));
2701 for _ in 0..v28 {
2702 v29.push({ let v30 = g.string();let v31 = { let v32 = g.count(); let mut v33 = Vec::with_capacity(v32.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v32 { v33.push({ let v34 = g.string();let v35 = if g.bool() { Some(g.i64()) } else { None }; crate::defs::p340::play::clientbound::AdvancementsProgressMappingValue { criterion_identifier: v34, criterion_progress: v35 } }); } v33 }; crate::defs::p340::play::clientbound::AdvancementsProgressMapping { key: v30, value: v31 } });
2703 }
2704 v29
2705 };
2706 let v36 = g.bool();
2707 Self {
2708 reset: v1,
2709 advancement_mapping: v2,
2710 identifiers: v24,
2711 progress_mapping: v27,
2712 show_advancements: v36,
2713 }
2714 }
2715 }
2716}
2717
2718#[cfg(feature = "v26_2")]
2719#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
2721#[non_exhaustive]
2722pub struct EntityUpdateAttributesPropertiesKey(pub i32);
2723#[cfg(feature = "v26_2")]
2724impl EntityUpdateAttributesPropertiesKey {
2725 pub const fn new(v: i32) -> Self {
2727 Self(v)
2728 }
2729 pub const AIR_DRAG_MODIFIER: Self = Self(0);
2731 pub const GENERIC_ARMOR: Self = Self(1);
2733 pub const GENERIC_ARMOR_TOUGHNESS: Self = Self(2);
2735 pub const GENERIC_ATTACK_DAMAGE: Self = Self(3);
2737 pub const GENERIC_ATTACK_KNOCKBACK: Self = Self(4);
2739 pub const GENERIC_ATTACK_SPEED: Self = Self(5);
2741 pub const BELOW_NAME_DISTANCE: Self = Self(6);
2743 pub const PLAYER_BLOCK_BREAK_SPEED: Self = Self(7);
2745 pub const PLAYER_BLOCK_INTERACTION_RANGE: Self = Self(8);
2747 pub const BOUNCINESS: Self = Self(9);
2749 pub const BURNING_TIME: Self = Self(10);
2751 pub const CAMERA_DISTANCE: Self = Self(11);
2753 pub const EXPLOSION_KNOCKBACK_RESISTANCE: Self = Self(12);
2755 pub const PLAYER_ENTITY_INTERACTION_RANGE: Self = Self(13);
2757 pub const GENERIC_FALL_DAMAGE_MULTIPLIER: Self = Self(14);
2759 pub const GENERIC_FLYING_SPEED: Self = Self(15);
2761 pub const GENERIC_FOLLOW_RANGE: Self = Self(16);
2763 pub const FRICTION_MODIFIER: Self = Self(17);
2765 pub const GENERIC_GRAVITY: Self = Self(18);
2767 pub const GENERIC_JUMP_STRENGTH: Self = Self(19);
2769 pub const GENERIC_KNOCKBACK_RESISTANCE: Self = Self(20);
2771 pub const GENERIC_LUCK: Self = Self(21);
2773 pub const GENERIC_MAX_ABSORPTION: Self = Self(22);
2775 pub const GENERIC_MAX_HEALTH: Self = Self(23);
2777 pub const MINING_EFFICIENCY: Self = Self(24);
2779 pub const MOVEMENT_EFFICIENCY: Self = Self(25);
2781 pub const GENERIC_MOVEMENT_SPEED: Self = Self(26);
2783 pub const NAME_TAG_DISTANCE: Self = Self(27);
2785 pub const OXYGEN_BONUS: Self = Self(28);
2787 pub const GENERIC_SAFE_FALL_DISTANCE: Self = Self(29);
2789 pub const GENERIC_SCALE: Self = Self(30);
2791 pub const SNEAKING_SPEED: Self = Self(31);
2793 pub const ZOMBIE_SPAWN_REINFORCEMENTS: Self = Self(32);
2795 pub const GENERIC_STEP_HEIGHT: Self = Self(33);
2797 pub const SUBMERGED_MINING_SPEED: Self = Self(34);
2799 pub const SWEEPING_DAMAGE_RATIO: Self = Self(35);
2801 pub const TEMPT_RANGE: Self = Self(36);
2803 pub const WATER_MOVEMENT_EFFICIENCY: Self = Self(37);
2805 pub const WAYPOINT_TRANSMIT_RANGE: Self = Self(38);
2807 pub const WAYPOINT_RECEIVE_RANGE: Self = Self(39);
2809 pub const fn name(self) -> Option<&'static str> {
2811 match self.0 {
2812 0 => Some("air_drag_modifier"),
2813 1 => Some("generic.armor"),
2814 2 => Some("generic.armor_toughness"),
2815 3 => Some("generic.attack_damage"),
2816 4 => Some("generic.attack_knockback"),
2817 5 => Some("generic.attack_speed"),
2818 6 => Some("below_name_distance"),
2819 7 => Some("player.block_break_speed"),
2820 8 => Some("player.block_interaction_range"),
2821 9 => Some("bounciness"),
2822 10 => Some("burning_time"),
2823 11 => Some("camera_distance"),
2824 12 => Some("explosion_knockback_resistance"),
2825 13 => Some("player.entity_interaction_range"),
2826 14 => Some("generic.fall_damage_multiplier"),
2827 15 => Some("generic.flying_speed"),
2828 16 => Some("generic.follow_range"),
2829 17 => Some("friction_modifier"),
2830 18 => Some("generic.gravity"),
2831 19 => Some("generic.jump_strength"),
2832 20 => Some("generic.knockback_resistance"),
2833 21 => Some("generic.luck"),
2834 22 => Some("generic.max_absorption"),
2835 23 => Some("generic.max_health"),
2836 24 => Some("mining_efficiency"),
2837 25 => Some("movement_efficiency"),
2838 26 => Some("generic.movement_speed"),
2839 27 => Some("name_tag_distance"),
2840 28 => Some("oxygen_bonus"),
2841 29 => Some("generic.safe_fall_distance"),
2842 30 => Some("generic.scale"),
2843 31 => Some("sneaking_speed"),
2844 32 => Some("zombie.spawn_reinforcements"),
2845 33 => Some("generic.step_height"),
2846 34 => Some("submerged_mining_speed"),
2847 35 => Some("sweeping_damage_ratio"),
2848 36 => Some("tempt_range"),
2849 37 => Some("water_movement_efficiency"),
2850 38 => Some("waypoint_transmit_range"),
2851 39 => Some("waypoint_receive_range"),
2852 _ => None,
2853 }
2854 }
2855}
2856#[cfg(feature = "v26_2")]
2857impl std::fmt::Debug for EntityUpdateAttributesPropertiesKey {
2858 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2859 match self.name() {
2860 Some(n) => write!(f, "EntityUpdateAttributesPropertiesKey::{n}"),
2861 None => write!(f, "EntityUpdateAttributesPropertiesKey({})", self.0),
2862 }
2863 }
2864}
2865
2866#[cfg(feature = "v26_2")]
2867#[derive(Debug, Clone, PartialEq)]
2869pub struct EntityUpdateAttributesProperties {
2870 pub key: crate::defs::p776::play::clientbound::EntityUpdateAttributesPropertiesKey,
2872 pub value: f64,
2874 pub modifiers:
2876 Vec<crate::defs::p775::play::clientbound::EntityUpdateAttributesPropertiesModifiers>,
2877}
2878
2879#[cfg(feature = "v26_2")]
2880#[derive(Debug, Clone, PartialEq)]
2882pub struct EntityUpdateAttributes<const V: i32> {
2883 pub entity_id: i32,
2885 pub properties: Vec<crate::defs::p776::play::clientbound::EntityUpdateAttributesProperties>,
2887}
2888#[cfg(feature = "v26_2")]
2889impl<const V: i32> Decode for EntityUpdateAttributes<V> {
2890 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2891 Ok({
2892 let v1 = r.read_varint()?;
2893 let v2 = {
2894 let v3 = {
2895 let c = r.read_varint()?;
2896 r.check_count(i64::from(c), 10)?
2897 };
2898 let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
2899 for _ in 0..v3 {
2900 v4.push({ let v5 = crate::defs::p776::play::clientbound::EntityUpdateAttributesPropertiesKey(r.read_varint()?);let v6 = r.read_f64()?;let v7 = { let v8 = { let c = r.read_varint()?; r.check_count(i64::from(c), 10)? }; let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v8 { v9.push({ let v10 = r.read_string()?;let v11 = r.read_f64()?;let v12 = r.read_i8()?; crate::defs::p775::play::clientbound::EntityUpdateAttributesPropertiesModifiers { uuid: v10, amount: v11, operation: v12 } }); } v9 }; crate::defs::p776::play::clientbound::EntityUpdateAttributesProperties { key: v5, value: v6, modifiers: v7 } });
2901 }
2902 v4
2903 };
2904 Self {
2905 entity_id: v1,
2906 properties: v2,
2907 }
2908 })
2909 }
2910}
2911#[cfg(feature = "v26_2")]
2912impl<const V: i32> Encode for EntityUpdateAttributes<V> {
2913 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2914 w.put_varint((*self).entity_id);
2915 w.put_len_varint((*self).properties.len())?;
2916 for v1 in (*self).properties.iter() {
2917 w.put_varint((*v1).key.0);
2918 w.put_f64((*v1).value);
2919 w.put_len_varint((*v1).modifiers.len())?;
2920 for v2 in (*v1).modifiers.iter() {
2921 w.put_string(&(*v2).uuid)?;
2922 w.put_f64((*v2).amount);
2923 w.put_i8((*v2).operation);
2924 }
2925 }
2926 Ok(())
2927 }
2928}
2929#[cfg(feature = "v26_2")]
2930#[cfg(feature = "testgen")]
2931impl<const V: i32> Generate for EntityUpdateAttributes<V> {
2932 fn generate(g: &mut Gen) -> Self {
2933 {
2934 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2935 let v2 = {
2936 let v3 = g.count();
2937 let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
2938 for _ in 0..v3 {
2939 v4.push({ let v5 = crate::defs::p776::play::clientbound::EntityUpdateAttributesPropertiesKey(g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) as i32);let v6 = g.f64();let v7 = { let v8 = g.count(); let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v8 { v9.push({ let v10 = g.string();let v11 = g.f64();let v12 = (g.int_in(-128, 127, &[]) as i8); crate::defs::p775::play::clientbound::EntityUpdateAttributesPropertiesModifiers { uuid: v10, amount: v11, operation: v12 } }); } v9 }; crate::defs::p776::play::clientbound::EntityUpdateAttributesProperties { key: v5, value: v6, modifiers: v7 } });
2940 }
2941 v4
2942 };
2943 Self {
2944 entity_id: v1,
2945 properties: v2,
2946 }
2947 }
2948 }
2949}
2950
2951#[cfg(feature = "v26_2")]
2952#[derive(Debug, Clone, PartialEq)]
2954pub struct DeclareRecipesStoneCutterRecipes {
2955 pub input: HolderSet,
2957 pub slot_display: crate::defs::p776::play::clientbound::SlotDisplay,
2959}
2960
2961#[cfg(feature = "v26_2")]
2962#[derive(Debug, Clone, PartialEq)]
2964pub struct DeclareRecipes<const V: i32> {
2965 pub recipes: Vec<crate::defs::p775::play::clientbound::DeclareRecipesRecipes>,
2967 pub stone_cutter_recipes:
2969 Vec<crate::defs::p776::play::clientbound::DeclareRecipesStoneCutterRecipes>,
2970}
2971#[cfg(feature = "v26_2")]
2972impl<const V: i32> Decode for DeclareRecipes<V> {
2973 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2974 Ok({
2975 let v1 = {
2976 let v2 = {
2977 let c = r.read_varint()?;
2978 r.check_count(i64::from(c), 2)?
2979 };
2980 let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
2981 for _ in 0..v2 {
2982 v3.push({
2983 let v4 = r.read_string()?;
2984 let v5 = {
2985 let v6 = {
2986 let c = r.read_varint()?;
2987 r.check_count(i64::from(c), 1)?
2988 };
2989 let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
2990 for _ in 0..v6 {
2991 v7.push(r.read_varint()?);
2992 }
2993 v7
2994 };
2995 crate::defs::p775::play::clientbound::DeclareRecipesRecipes {
2996 name: v4,
2997 items: v5,
2998 }
2999 });
3000 }
3001 v3
3002 };
3003 let v8 = {
3004 let v9 = {
3005 let c = r.read_varint()?;
3006 r.check_count(i64::from(c), 2)?
3007 };
3008 let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT));
3009 for _ in 0..v9 {
3010 v10.push({
3011 let v11 = <HolderSet as Decode>::decode(r)?;
3012 let v12 =
3013 <crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(
3014 r,
3015 )?;
3016 crate::defs::p776::play::clientbound::DeclareRecipesStoneCutterRecipes {
3017 input: v11,
3018 slot_display: v12,
3019 }
3020 });
3021 }
3022 v10
3023 };
3024 Self {
3025 recipes: v1,
3026 stone_cutter_recipes: v8,
3027 }
3028 })
3029 }
3030}
3031#[cfg(feature = "v26_2")]
3032impl<const V: i32> Encode for DeclareRecipes<V> {
3033 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3034 w.put_len_varint((*self).recipes.len())?;
3035 for v1 in (*self).recipes.iter() {
3036 w.put_string(&(*v1).name)?;
3037 w.put_len_varint((*v1).items.len())?;
3038 for v2 in (*v1).items.iter() {
3039 w.put_varint((*v2));
3040 }
3041 }
3042 w.put_len_varint((*self).stone_cutter_recipes.len())?;
3043 for v3 in (*self).stone_cutter_recipes.iter() {
3044 (*v3).input.encode(w)?;
3045 (*v3).slot_display.encode(w)?;
3046 }
3047 Ok(())
3048 }
3049}
3050#[cfg(feature = "v26_2")]
3051#[cfg(feature = "testgen")]
3052impl<const V: i32> Generate for DeclareRecipes<V> {
3053 fn generate(g: &mut Gen) -> Self {
3054 {
3055 let v1 = {
3056 let v2 = g.count();
3057 let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
3058 for _ in 0..v2 {
3059 v3.push({
3060 let v4 = g.string();
3061 let v5 = {
3062 let v6 = g.count();
3063 let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
3064 for _ in 0..v6 {
3065 v7.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
3066 }
3067 v7
3068 };
3069 crate::defs::p775::play::clientbound::DeclareRecipesRecipes {
3070 name: v4,
3071 items: v5,
3072 }
3073 });
3074 }
3075 v3
3076 };
3077 let v8 = {
3078 let v9 = g.count();
3079 let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT));
3080 for _ in 0..v9 {
3081 v10.push({ let v11 = <HolderSet as Generate>::generate(g);let v12 = <crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(g); crate::defs::p776::play::clientbound::DeclareRecipesStoneCutterRecipes { input: v11, slot_display: v12 } });
3082 }
3083 v10
3084 };
3085 Self {
3086 recipes: v1,
3087 stone_cutter_recipes: v8,
3088 }
3089 }
3090 }
3091}