From cc527c26eaad9d196024a58e8b98d145cc42745e Mon Sep 17 00:00:00 2001 From: Snowiiii Date: Sat, 3 Aug 2024 11:33:50 +0200 Subject: [PATCH] Add Clientbound Game Event --- pumpkin-protocol/src/client/play/mod.rs | 18 ++++++++++++++++++ pumpkin/src/server.rs | 7 +++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/pumpkin-protocol/src/client/play/mod.rs b/pumpkin-protocol/src/client/play/mod.rs index 34730eb33..b3d04d7a7 100644 --- a/pumpkin-protocol/src/client/play/mod.rs +++ b/pumpkin-protocol/src/client/play/mod.rs @@ -168,4 +168,22 @@ impl ClientPacket for CLogin { } } +pub struct CGameEvent { + event: u8, + value: f32, +} +impl CGameEvent { + pub fn new(event: u8, value: f32) -> Self { + Self { event, value } + } +} + +impl ClientPacket for CGameEvent { + const PACKET_ID: VarInt = 0x22; + + fn write(&self, bytebuf: &mut ByteBuffer) { + bytebuf.put_u8(self.event); + bytebuf.put_f32(self.value); + } +} diff --git a/pumpkin/src/server.rs b/pumpkin/src/server.rs index f02c039ba..7a6b71f30 100644 --- a/pumpkin/src/server.rs +++ b/pumpkin/src/server.rs @@ -8,7 +8,7 @@ use mio::{event::Event, Poll}; use pumpkin_protocol::{ client::{ config::CPluginMessage, - play::{ CLogin}, + play::{CGameEvent, CLogin}, }, PacketError, Players, Sample, StatusResponse, VarInt, VarInt32, Version, }; @@ -127,7 +127,10 @@ impl Server { )) .unwrap_or_else(|e| client.kick(&e.to_string())); - + // Start waiting for level chunks + client + .send_packet(CGameEvent::new(13, 0.0)) + .unwrap_or_else(|e| client.kick(&e.to_string())); dbg!("spawning player"); client.player = Some(player); }