diff --git a/pumpkin-protocol/src/client/config/mod.rs b/pumpkin-protocol/src/client/config/mod.rs index 43c5568c8..112b7e87b 100644 --- a/pumpkin-protocol/src/client/config/mod.rs +++ b/pumpkin-protocol/src/client/config/mod.rs @@ -1,13 +1,15 @@ -use crate::{bytebuf::ByteBuffer, ClientPacket, KnownPack, VarInt}; +use crate::{bytebuf::ByteBuffer, ClientPacket, Identifier, KnownPack, VarInt}; pub struct CCookieRequest { - // TODO + key: Identifier, } impl ClientPacket for CCookieRequest { const PACKET_ID: VarInt = 0x00; - fn write(&self, bytebuf: &mut ByteBuffer) {} + fn write(&self, bytebuf: &mut ByteBuffer) { + bytebuf.put_string(&self.key); + } } pub struct CPluginMessage<'a> { @@ -115,7 +117,7 @@ impl<'a> ClientPacket for CRegistryData<'a> { fn write(&self, bytebuf: &mut ByteBuffer) { bytebuf.put_string(self.registry_id); bytebuf.put_list::(self.entries, |p, v| { - p.put_string(&v.entry_id); + p.put_string(v.entry_id); p.put_bool(!v.data.is_empty()); p.put_slice(&v.data); }); diff --git a/pumpkin-protocol/src/client/login/mod.rs b/pumpkin-protocol/src/client/login/mod.rs index 2562d4479..9ade90920 100644 --- a/pumpkin-protocol/src/client/login/mod.rs +++ b/pumpkin-protocol/src/client/login/mod.rs @@ -58,25 +58,24 @@ pub struct CSetCompression { threshold: VarInt, } -pub struct CLoginSuccess { +pub struct CLoginSuccess<'a> { pub uuid: uuid::Uuid, pub username: String, // 16 - pub num_of_props: VarInt, - // pub property: Property, + pub properties: &'a [Property], pub strict_error_handling: bool, } -impl CLoginSuccess { +impl<'a> CLoginSuccess<'a> { pub fn new( uuid: uuid::Uuid, username: String, - num_of_props: VarInt, + properties: &'a [Property], strict_error_handling: bool, ) -> Self { Self { uuid, username, - num_of_props, + properties, strict_error_handling, } } @@ -89,14 +88,18 @@ pub struct Property { signature: Option, } -impl ClientPacket for CLoginSuccess { +impl<'a> ClientPacket for CLoginSuccess<'a> { const PACKET_ID: VarInt = 0x02; fn write(&self, bytebuf: &mut ByteBuffer) { bytebuf.put_uuid(self.uuid); bytebuf.put_string(&self.username); - bytebuf.put_var_int(self.num_of_props); - // Todo + bytebuf.put_list::(self.properties, |p, v| { + p.put_string(&v.name); + p.put_string(&v.value); + p.put_bool(v.is_signed); + p.put_option(&v.signature, |p, v| p.put_string(v.as_str())) + }); bytebuf.put_bool(self.strict_error_handling); } } diff --git a/pumpkin-protocol/src/client/play/mod.rs b/pumpkin-protocol/src/client/play/mod.rs index a675b3bb3..2ed0b4c79 100644 --- a/pumpkin-protocol/src/client/play/mod.rs +++ b/pumpkin-protocol/src/client/play/mod.rs @@ -248,6 +248,7 @@ pub struct CChunkDataUpdateLight { } impl CChunkDataUpdateLight { + #[allow(clippy::too_many_arguments)] pub fn new( chunk_x: i32, chunk_y: i32, diff --git a/pumpkin-protocol/src/server/config/mod.rs b/pumpkin-protocol/src/server/config/mod.rs index 89e30e9fa..2ee53ecd4 100644 --- a/pumpkin-protocol/src/server/config/mod.rs +++ b/pumpkin-protocol/src/server/config/mod.rs @@ -55,7 +55,7 @@ impl ServerPacket for SAcknowledgeFinishConfig { } pub struct SKnownPacks { - known_pack_count: VarInt, + pub known_pack_count: VarInt, // known_packs: &'a [KnownPack] } diff --git a/pumpkin-protocol/src/server/login/mod.rs b/pumpkin-protocol/src/server/login/mod.rs index ad6a29e4f..8e73b5542 100644 --- a/pumpkin-protocol/src/server/login/mod.rs +++ b/pumpkin-protocol/src/server/login/mod.rs @@ -41,9 +41,9 @@ impl ServerPacket for SEncryptionResponse { } pub struct SLoginPluginResponse<'a> { - message_id: VarInt, - successful: bool, - data: Option<&'a [u8]>, + pub message_id: VarInt, + pub successful: bool, + pub data: Option<&'a [u8]>, } impl<'a> ServerPacket for SLoginPluginResponse<'a> { diff --git a/pumpkin-registry/src/chat_type.rs b/pumpkin-registry/src/chat_type.rs index afcab7b28..8b1378917 100644 --- a/pumpkin-registry/src/chat_type.rs +++ b/pumpkin-registry/src/chat_type.rs @@ -1,13 +1 @@ -use serde::Serialize; -#[derive(Debug, Clone, Serialize)] -pub struct ChatType { - chat: Decoration, - narration: Decoration, -} -#[derive(Debug, Clone, Serialize)] -struct Decoration { - translation_key: String, - // style: Option<> - parameters: Vec, -} diff --git a/pumpkin-registry/src/damage_type.rs b/pumpkin-registry/src/damage_type.rs index d52986b23..36ccfd5d9 100644 --- a/pumpkin-registry/src/damage_type.rs +++ b/pumpkin-registry/src/damage_type.rs @@ -67,7 +67,7 @@ pub(super) fn entires() -> Vec> { let items: Vec<_> = NAMES .iter() .map(|name| RegistryEntry { - entry_id: (*name).into(), + entry_id: name, data: fastnbt::to_bytes_with_opts( &DamageType { exhaustion: 0.1, diff --git a/pumpkin-world/src/chunk.rs b/pumpkin-world/src/chunk.rs index 502d4a961..6a9d739f5 100644 --- a/pumpkin-world/src/chunk.rs +++ b/pumpkin-world/src/chunk.rs @@ -1,4 +1,4 @@ -use fastnbt::{nbt, SerOpts}; +use fastnbt::nbt; pub const BLOCKS_AND_BIOMES: [u8; 2000] = [0x80; 2000]; pub const SKY_LIGHT_ARRAYS: [FixedArray; 26] = [FixedArray([0xff; 2048]); 26]; @@ -11,6 +11,12 @@ pub struct TestChunk { pub heightmap: Vec, } +impl Default for TestChunk { + fn default() -> Self { + Self::new() + } +} + impl TestChunk { pub fn new() -> Self { let bytes = fastnbt::to_bytes(&nbt!({"MOTION_BLOCKING": [L; 123, 256]})).unwrap(); diff --git a/pumpkin-world/src/lib.rs b/pumpkin-world/src/lib.rs index 1bbfbb756..30f2f934c 100644 --- a/pumpkin-world/src/lib.rs +++ b/pumpkin-world/src/lib.rs @@ -1,6 +1,6 @@ use std::{fs::File, path::Path}; -use fastanvil::{complete, Chunk, Region}; +use fastanvil::Region; pub mod chunk; diff --git a/pumpkin/src/client/client_packet.rs b/pumpkin/src/client/client_packet.rs index 6e291d18d..2852c3786 100644 --- a/pumpkin/src/client/client_packet.rs +++ b/pumpkin/src/client/client_packet.rs @@ -109,7 +109,7 @@ impl ClientPacketProcessor for Client { if let Some(uuid) = self.uuid { if let Some(name) = &self.name { - let packet = CLoginSuccess::new(uuid, name.clone(), 0, false); + let packet = CLoginSuccess::new(uuid, name.clone(), &[], false); // todo self.send_packet(packet) .unwrap_or_else(|e| self.kick(&e.to_string())); } else { diff --git a/pumpkin/src/client/mod.rs b/pumpkin/src/client/mod.rs index ae41fae07..e77c98ca8 100644 --- a/pumpkin/src/client/mod.rs +++ b/pumpkin/src/client/mod.rs @@ -35,14 +35,14 @@ pub mod player_packet; use client_packet::ClientPacketProcessor; pub struct PlayerConfig { - locale: String, // 16 - view_distance: i8, - chat_mode: ChatMode, - chat_colors: bool, - skin_parts: u8, - main_hand: Hand, - text_filtering: bool, - server_listing: bool, + pub locale: String, // 16 + pub view_distance: i8, + pub chat_mode: ChatMode, + pub chat_colors: bool, + pub skin_parts: u8, + pub main_hand: Hand, + pub text_filtering: bool, + pub server_listing: bool, } pub struct Client { diff --git a/pumpkin/src/client/player_packet.rs b/pumpkin/src/client/player_packet.rs index 871b3d095..e8e624a39 100644 --- a/pumpkin/src/client/player_packet.rs +++ b/pumpkin/src/client/player_packet.rs @@ -1,6 +1,6 @@ use pumpkin_protocol::server::play::SConfirmTeleport; -use crate::{entity::player::Player, server::Server}; +use crate::server::Server; use super::Client; diff --git a/pumpkin/src/server.rs b/pumpkin/src/server.rs index 3b1f98bd3..f7809643a 100644 --- a/pumpkin/src/server.rs +++ b/pumpkin/src/server.rs @@ -1,6 +1,5 @@ use std::{ io::Cursor, - rc::Rc, sync::atomic::{AtomicI32, Ordering}, }; @@ -9,14 +8,11 @@ use mio::{event::Event, Poll}; use pumpkin_protocol::{ client::{ config::CPluginMessage, - play::{CChunkDataUpdateLight, CGameEvent, CLogin, CSyncPlayerPostion, SkyLight}, + play::{CChunkDataUpdateLight, CGameEvent, CLogin, CSyncPlayerPostion}, }, BitSet, PacketError, Players, Sample, StatusResponse, VarInt, VarInt32, Version, }; -use pumpkin_world::{ - chunk::{TestChunk, SKY_LIGHT_ARRAYS}, - World, -}; +use pumpkin_world::chunk::TestChunk; use rsa::{rand_core::OsRng, traits::PublicKeyParts, RsaPrivateKey, RsaPublicKey}; use serde::{Deserialize, Serialize};