From ad89862f9f77a1aad9fa9ad62dad16bef13ae1d9 Mon Sep 17 00:00:00 2001 From: zp3x <90056490+zp3x@users.noreply.github.com> Date: Tue, 30 Jul 2024 22:21:05 +0200 Subject: [PATCH] Add Clientbound ChangeDifficulty Packet --- pumpkin/src/protocol/client/play/mod.rs | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pumpkin/src/protocol/client/play/mod.rs b/pumpkin/src/protocol/client/play/mod.rs index 0f6eb665e..9aeb3d2a2 100644 --- a/pumpkin/src/protocol/client/play/mod.rs +++ b/pumpkin/src/protocol/client/play/mod.rs @@ -3,6 +3,35 @@ use crate::{ protocol::{ClientPacket, VarInt}, }; +pub struct CChangeDifficulty { + + difficulty: u8, + locked: bool + +} + +impl CChangeDifficulty { + pub fn new( + difficulty: u8, + locked: bool + ) -> Self { + + Self { + difficulty, + locked + } + + } +} + +impl ClientPacket for CChangeDifficulty { + const PACKET_ID: VarInt = 0x0B; + + fn write(&self, bytebuf: &mut crate::protocol::bytebuf::buffer::ByteBuffer) { + bytebuf.write_u8(self.difficulty); + bytebuf.write_bool(self.locked); + } +} pub struct CLogin { entity_id: i32, is_hardcore: bool,