Skip to main content

ghast_protocol/generated/defs/p47/status/
clientbound.rs

1// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
2// (data/pc/1.8/protocol.json). Do not edit; run `cargo run -p ghast-codegen-protocol`.
3// minecraft-data is MIT licensed, Copyright (c) 2015 PrismarineJS; see the NOTICE file
4// in crates/ghast-protocol/src/generated/.
5
6//! Clientbound packets of the status state.
7
8#![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(any(
29    feature = "v1_8",
30    feature = "v1_12_2",
31    feature = "v1_16_5",
32    feature = "v26_1",
33    feature = "v26_2"
34))]
35/// `server_info` (clientbound status).
36#[derive(Debug, Clone, PartialEq)]
37pub struct ServerInfo<const V: i32> {
38    /// `response`
39    pub response: ByteString,
40}
41#[cfg(any(
42    feature = "v1_8",
43    feature = "v1_12_2",
44    feature = "v1_16_5",
45    feature = "v26_1",
46    feature = "v26_2"
47))]
48impl<const V: i32> Decode for ServerInfo<V> {
49    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
50        Ok({
51            let v1 = r.read_string()?;
52            Self { response: v1 }
53        })
54    }
55}
56#[cfg(any(
57    feature = "v1_8",
58    feature = "v1_12_2",
59    feature = "v1_16_5",
60    feature = "v26_1",
61    feature = "v26_2"
62))]
63impl<const V: i32> Encode for ServerInfo<V> {
64    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
65        w.put_string(&(*self).response)?;
66        Ok(())
67    }
68}
69#[cfg(any(
70    feature = "v1_8",
71    feature = "v1_12_2",
72    feature = "v1_16_5",
73    feature = "v26_1",
74    feature = "v26_2"
75))]
76#[cfg(feature = "testgen")]
77impl<const V: i32> Generate for ServerInfo<V> {
78    fn generate(g: &mut Gen) -> Self {
79        {
80            let v1 = g.string();
81            Self { response: v1 }
82        }
83    }
84}
85
86#[cfg(any(
87    feature = "v1_8",
88    feature = "v1_12_2",
89    feature = "v1_16_5",
90    feature = "v26_1",
91    feature = "v26_2"
92))]
93/// `ping` (clientbound status).
94#[derive(Debug, Clone, PartialEq)]
95pub struct Ping<const V: i32> {
96    /// `time`
97    pub time: i64,
98}
99#[cfg(any(
100    feature = "v1_8",
101    feature = "v1_12_2",
102    feature = "v1_16_5",
103    feature = "v26_1",
104    feature = "v26_2"
105))]
106impl<const V: i32> Decode for Ping<V> {
107    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
108        Ok({
109            let v1 = r.read_i64()?;
110            Self { time: v1 }
111        })
112    }
113}
114#[cfg(any(
115    feature = "v1_8",
116    feature = "v1_12_2",
117    feature = "v1_16_5",
118    feature = "v26_1",
119    feature = "v26_2"
120))]
121impl<const V: i32> Encode for Ping<V> {
122    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
123        w.put_i64((*self).time);
124        Ok(())
125    }
126}
127#[cfg(any(
128    feature = "v1_8",
129    feature = "v1_12_2",
130    feature = "v1_16_5",
131    feature = "v26_1",
132    feature = "v26_2"
133))]
134#[cfg(feature = "testgen")]
135impl<const V: i32> Generate for Ping<V> {
136    fn generate(g: &mut Gen) -> Self {
137        {
138            let v1 = g.i64();
139            Self { time: v1 }
140        }
141    }
142}