blob: b1323f50fc33c7364add7d41c226a381f0fe7a51 (
plain)
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
|
use std::{
hash::Hash,
io::{Read, Write},
};
use crate::mc_buf::{Readable, Writable};
use super::LoginPacket;
#[derive(Hash, Clone, Debug)]
pub struct ClientboundLoginCompressionPacket {
pub compression_threshold: i32,
}
impl ClientboundLoginCompressionPacket {
pub fn get(self) -> LoginPacket {
LoginPacket::ClientboundLoginCompressionPacket(self)
}
pub fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
buf.write_varint(self.compression_threshold).unwrap();
Ok(())
}
pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> {
let compression_threshold = buf.read_varint()?;
Ok(ClientboundLoginCompressionPacket {
compression_threshold,
}
.get())
}
}
|