Transition more Clientbound packets to new system

This commit is contained in:
Snowiiii committed 2024-08-07 15:08:16 +02:00
1 parent a9bd4e2326
commit bb6e3d9478
10 files changed
+57 -77

No files matched your search

+5 -37
View File
@@ -1,7 +1,9 @@
use pumpkin_macros::packet;
use serde::Serialize;
use crate::{bytebuf::ByteBuffer, ClientPacket, VarInt};
use crate::VarInt;
#[derive(Serialize)]
#[packet(0x2B)]
pub struct CLogin {
entity_id: i32,
@@ -20,9 +22,7 @@ pub struct CLogin {
previous_gamemode: i8,
debug: bool,
is_flat: bool,
has_death_loc: bool,
death_dimension_name: Option<String>,
death_loc: Option<i64>, // POSITION NOT STRING
death_dimension_name: Option<(String, i64)>, // POSITION NOT STRING
portal_cooldown: VarInt,
enforce_secure_chat: bool,
}
@@ -46,9 +46,7 @@ impl CLogin {
previous_gamemode: i8,
debug: bool,
is_flat: bool,
has_death_loc: bool,
death_dimension_name: Option<String>,
death_loc: Option<i64>, // todo add block pos
death_dimension_name: Option<(String, i64)>,
portal_cooldown: VarInt,
enforce_secure_chat: bool,
) -> Self {
@@ -69,39 +67,9 @@ impl CLogin {
previous_gamemode,
debug,
is_flat,
has_death_loc,
death_dimension_name,
death_loc,
portal_cooldown,
enforce_secure_chat,
}
}
}
impl ClientPacket for CLogin {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_i32(self.entity_id);
bytebuf.put_bool(self.is_hardcore);
bytebuf.put_list(&self.dimension_names, |buf, v| buf.put_string(v));
bytebuf.put_var_int(&self.max_players);
bytebuf.put_var_int(&self.view_distance);
bytebuf.put_var_int(&self.simulated_distance);
bytebuf.put_bool(self.reduced_debug_info);
bytebuf.put_bool(self.enabled_respawn_screen);
bytebuf.put_bool(self.limited_crafting);
bytebuf.put_var_int(&self.dimension_type);
bytebuf.put_string(&self.dimension_name);
bytebuf.put_i64(self.hashed_seed);
bytebuf.put_u8(self.game_mode);
bytebuf.put_i8(self.previous_gamemode);
bytebuf.put_bool(self.debug);
bytebuf.put_bool(self.is_flat);
bytebuf.put_bool(self.has_death_loc);
if self.has_death_loc {
bytebuf.put_string(self.death_dimension_name.as_ref().unwrap());
bytebuf.put_i64(self.death_loc.unwrap());
}
bytebuf.put_var_int(&self.portal_cooldown);
bytebuf.put_bool(self.enforce_secure_chat);
}
}