diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8ffa4b70e..b28c669c0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,7 @@ We appreciate your interest in contributing to Pumpkin! This document outlines the guidelines for submitting bug reports, feature suggestions, and code changes. Getting Started -The easisty way to get started is by asking for help in our [discord](https://discord.gg/wT8XjrjKkf) +The easiest way to get started is by asking for help in our [discord](https://discord.gg/wT8XjrjKkf) ### How to Contribute diff --git a/README.md b/README.md index 98b5e06aa..b48027f03 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ and customizable experience. It prioritizes performance and player enjoyment whi ![image](https://github.com/user-attachments/assets/7e2e865e-b150-4675-a2d5-b52f9900378e) -### What Pumpkin wants to achive: +### What Pumpkin wants to achieve: - **Performance**: Leveraging multi-threading for maximum speed and efficiency. - **Compatibility**: Supports the latest Minecraft server version and adheres to vanilla game mechanics. - **Security**: Prioritizes security by preventing known exploits. @@ -83,13 +83,13 @@ Make sure to generate chunks close to (0,0) since that is where the player gets Then run: > [!NOTE] -> This can take a while. Because we enabled heavy optimations for release builds +> This can take a while. Because we enabled heavy optimizations for release builds ``` RUSTFLAGS="-C target-cpu=native" cargo run --release ``` ## Contributions -Contributions are welcome!. See [CONTRIBUTING.md](CONTRIBUTING.md) +Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) ## Communication Consider joining our [discord](https://discord.gg/wT8XjrjKkf) to stay up-to-date on events, updates, and connect with other members. diff --git a/pumpkin-inventory/src/player.rs b/pumpkin-inventory/src/player.rs index 4e846999d..3108b23f8 100644 --- a/pumpkin-inventory/src/player.rs +++ b/pumpkin-inventory/src/player.rs @@ -1,5 +1,6 @@ use pumpkin_world::item::Item; +#[allow(dead_code)] pub struct PlayerInventory { // Main Inventory + Hotbar items: [Option; 36], @@ -21,12 +22,12 @@ impl PlayerInventory { items: [None; 36], armor: [None; 4], offhand: None, - // TODO: What when player spawns in with an diffrent index ? + // TODO: What when player spawns in with an different index ? selected: 0, } } - pub fn set_slot(slot: u32, item: Item) {} + pub fn set_slot(_slot: u32, _item: Item) {} pub fn set_selected(&mut self, slot: i16) { assert!((0..9).contains(&slot)); diff --git a/pumpkin-protocol/src/bytebuf/packet_id.rs b/pumpkin-protocol/src/bytebuf/packet_id.rs index f5dde8413..635a8051e 100644 --- a/pumpkin-protocol/src/bytebuf/packet_id.rs +++ b/pumpkin-protocol/src/bytebuf/packet_id.rs @@ -7,7 +7,7 @@ use crate::{BitSet, ClientPacket, ServerPacket, VarInt, VarIntType}; use super::{deserializer, serializer, ByteBuffer, DeserializerError}; -impl Serialize for BitSet<'static> { +impl<'a> Serialize for BitSet<'a> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/pumpkin-protocol/src/client/config/c_add_resource_pack.rs b/pumpkin-protocol/src/client/config/c_add_resource_pack.rs index 2980d85d0..ae8212aba 100644 --- a/pumpkin-protocol/src/client/config/c_add_resource_pack.rs +++ b/pumpkin-protocol/src/client/config/c_add_resource_pack.rs @@ -2,23 +2,25 @@ use pumpkin_macros::packet; use pumpkin_text::TextComponent; use serde::Serialize; +use crate::uuid::UUID; + #[derive(Serialize)] #[packet(0x09)] -pub struct CConfigAddResourcePack { - uuid: uuid::Uuid, - url: String, - hash: String, +pub struct CConfigAddResourcePack<'a> { + uuid: UUID, + url: &'a str, + hash: &'a str, // max 40 forced: bool, - prompt_message: Option, + prompt_message: Option>, } -impl CConfigAddResourcePack { +impl<'a> CConfigAddResourcePack<'a> { pub fn new( - uuid: uuid::Uuid, - url: String, - hash: String, + uuid: UUID, + url: &'a str, + hash: &'a str, forced: bool, - prompt_message: Option, + prompt_message: Option>, ) -> Self { Self { uuid, diff --git a/pumpkin-protocol/src/client/config/c_plugin_message.rs b/pumpkin-protocol/src/client/config/c_plugin_message.rs index bdb7692b4..c320ca291 100644 --- a/pumpkin-protocol/src/client/config/c_plugin_message.rs +++ b/pumpkin-protocol/src/client/config/c_plugin_message.rs @@ -1,8 +1,6 @@ use pumpkin_macros::packet; use serde::Serialize; -use crate::{bytebuf::ByteBuffer, ClientPacket}; - #[derive(Serialize)] #[packet(0x01)] pub struct CPluginMessage<'a> { diff --git a/pumpkin-protocol/src/client/play/c_actionbar.rs b/pumpkin-protocol/src/client/play/c_actionbar.rs index d9046de06..fb8fe68ba 100644 --- a/pumpkin-protocol/src/client/play/c_actionbar.rs +++ b/pumpkin-protocol/src/client/play/c_actionbar.rs @@ -4,12 +4,12 @@ use serde::Serialize; #[derive(Serialize)] #[packet(0x4C)] -pub struct CActionBar { - action_bar: TextComponent, +pub struct CActionBar<'a> { + action_bar: TextComponent<'a>, } -impl CActionBar { - pub fn new(action_bar: TextComponent) -> Self { +impl<'a> CActionBar<'a> { + pub fn new(action_bar: TextComponent<'a>) -> Self { Self { action_bar } } } diff --git a/pumpkin-protocol/src/client/play/c_chunk_data.rs b/pumpkin-protocol/src/client/play/c_chunk_data.rs index eec44e47c..484be4fd6 100644 --- a/pumpkin-protocol/src/client/play/c_chunk_data.rs +++ b/pumpkin-protocol/src/client/play/c_chunk_data.rs @@ -32,7 +32,7 @@ impl<'a> ClientPacket for CChunkData<'a> { data_buf.put_i16(block_count); //// Block states - let palette = chunk.into_iter().dedup().collect_vec(); + let palette = chunk.iter().dedup().collect_vec(); // TODO: make dynamic block_size work // TODO: make direct block_size work enum PaletteType { @@ -63,7 +63,7 @@ impl<'a> ClientPacket for CChunkData<'a> { palette.iter().enumerate().for_each(|(i, id)| { palette_map.insert(*id, i); // Palette - data_buf.put_var_int(&VarInt(**id as i32)); + data_buf.put_var_int(&VarInt(**id)); }); for block_clump in chunk.chunks(64 / block_size as usize) { let mut out_long: i64 = 0; @@ -109,7 +109,7 @@ impl<'a> ClientPacket for CChunkData<'a> { // Size buf.put_var_int(&VarInt(data_buf.buf().len() as i32)); // Data - buf.put_slice(&data_buf.buf()); + buf.put_slice(data_buf.buf()); // TODO: block entities buf.put_var_int(&VarInt(0)); diff --git a/pumpkin-protocol/src/client/play/c_disguised_chat_message.rs b/pumpkin-protocol/src/client/play/c_disguised_chat_message.rs index c1228080c..65b43b9b8 100644 --- a/pumpkin-protocol/src/client/play/c_disguised_chat_message.rs +++ b/pumpkin-protocol/src/client/play/c_disguised_chat_message.rs @@ -6,19 +6,19 @@ use crate::VarInt; #[derive(Serialize)] #[packet(0x1E)] -pub struct CDisguisedChatMessage { - message: TextComponent, +pub struct CDisguisedChatMessage<'a> { + message: TextComponent<'a>, chat_type: VarInt, - sender_name: TextComponent, - target_name: Option, + sender_name: TextComponent<'a>, + target_name: Option>, } -impl CDisguisedChatMessage { +impl<'a> CDisguisedChatMessage<'a> { pub fn new( - message: TextComponent, + message: TextComponent<'a>, chat_type: VarInt, - sender_name: TextComponent, - target_name: Option, + sender_name: TextComponent<'a>, + target_name: Option>, ) -> Self { Self { message, diff --git a/pumpkin-protocol/src/client/play/c_login.rs b/pumpkin-protocol/src/client/play/c_login.rs index 11f923347..0e0b12224 100644 --- a/pumpkin-protocol/src/client/play/c_login.rs +++ b/pumpkin-protocol/src/client/play/c_login.rs @@ -1,7 +1,7 @@ use pumpkin_macros::packet; use serde::Serialize; -use crate::VarInt; +use crate::{position::WorldPosition, VarInt}; #[derive(Serialize)] #[packet(0x2B)] @@ -23,7 +23,7 @@ pub struct CLogin<'a> { previous_gamemode: i8, debug: bool, is_flat: bool, - death_dimension_name: Option<(String, i64)>, // POSITION NOT STRING + death_dimension_name: Option<(WorldPosition, i64)>, portal_cooldown: VarInt, enforce_secure_chat: bool, } @@ -47,7 +47,7 @@ impl<'a> CLogin<'a> { previous_gamemode: i8, debug: bool, is_flat: bool, - death_dimension_name: Option<(String, i64)>, + death_dimension_name: Option<(WorldPosition, i64)>, portal_cooldown: VarInt, enforce_secure_chat: bool, ) -> Self { diff --git a/pumpkin-protocol/src/client/play/c_open_screen.rs b/pumpkin-protocol/src/client/play/c_open_screen.rs index 1b5905230..7c5b07a22 100644 --- a/pumpkin-protocol/src/client/play/c_open_screen.rs +++ b/pumpkin-protocol/src/client/play/c_open_screen.rs @@ -6,14 +6,14 @@ use crate::VarInt; #[derive(Serialize)] #[packet(0x33)] -pub struct COpenScreen { +pub struct COpenScreen<'a> { window_id: VarInt, window_type: VarInt, - window_title: TextComponent, + window_title: TextComponent<'a>, } -impl COpenScreen { - pub fn new(window_id: VarInt, window_type: VarInt, window_title: TextComponent) -> Self { +impl<'a> COpenScreen<'a> { + pub fn new(window_id: VarInt, window_type: VarInt, window_title: TextComponent<'a>) -> Self { Self { window_id, window_type, diff --git a/pumpkin-protocol/src/client/play/c_particle.rs b/pumpkin-protocol/src/client/play/c_particle.rs index 5ef4f1b91..c3fa35a17 100644 --- a/pumpkin-protocol/src/client/play/c_particle.rs +++ b/pumpkin-protocol/src/client/play/c_particle.rs @@ -21,6 +21,7 @@ pub struct CParticle<'a> { } impl<'a> CParticle<'a> { + #[allow(clippy::too_many_arguments)] pub fn new( long_distance: bool, x: f64, diff --git a/pumpkin-protocol/src/client/play/c_play_disconnect.rs b/pumpkin-protocol/src/client/play/c_play_disconnect.rs index e5aa3f197..dd861d732 100644 --- a/pumpkin-protocol/src/client/play/c_play_disconnect.rs +++ b/pumpkin-protocol/src/client/play/c_play_disconnect.rs @@ -4,12 +4,12 @@ use serde::Serialize; #[derive(Serialize)] #[packet(0x1D)] -pub struct CPlayDisconnect { - reason: TextComponent, +pub struct CPlayDisconnect<'a> { + reason: TextComponent<'a>, } -impl CPlayDisconnect { - pub fn new(reason: TextComponent) -> Self { +impl<'a> CPlayDisconnect<'a> { + pub fn new(reason: TextComponent<'a>) -> Self { Self { reason } } } diff --git a/pumpkin-protocol/src/client/play/c_player_chat_message.rs b/pumpkin-protocol/src/client/play/c_player_chat_message.rs index 47726a1f3..ade16d855 100644 --- a/pumpkin-protocol/src/client/play/c_player_chat_message.rs +++ b/pumpkin-protocol/src/client/play/c_player_chat_message.rs @@ -11,19 +11,18 @@ pub struct CPlayerChatMessage<'a> { sender: UUID, index: VarInt, message_signature: Option<&'a [u8]>, - message: String, + message: &'a str, timestamp: i64, salt: i64, previous_messages_count: VarInt, previous_messages: &'a [PreviousMessage<'a>], // max 20 - unsigned_content: Option, + unsigned_content: Option>, /// See `FilterType` filter_type: VarInt, - // TODO: THIS IS A HACK, We currently don't support writing or reading bitsets - filter_type_bits: bool, + filter_type_bits: Option>, chat_type: VarInt, - sender_name: TextComponent, - target_name: Option, + sender_name: TextComponent<'a>, + target_name: Option>, } impl<'a> CPlayerChatMessage<'a> { @@ -32,15 +31,16 @@ impl<'a> CPlayerChatMessage<'a> { sender: UUID, index: VarInt, message_signature: Option<&'a [u8]>, - message: String, + message: &'a str, timestamp: i64, salt: i64, previous_messages: &'a [PreviousMessage<'a>], - unsigned_content: Option, + unsigned_content: Option>, filter_type: VarInt, + filter_type_bits: Option>, chat_type: VarInt, - sender_name: TextComponent, - target_name: Option, + sender_name: TextComponent<'a>, + target_name: Option>, ) -> Self { Self { sender, @@ -53,7 +53,7 @@ impl<'a> CPlayerChatMessage<'a> { previous_messages, unsigned_content, filter_type, - filter_type_bits: false, + filter_type_bits, chat_type, sender_name, target_name, diff --git a/pumpkin-protocol/src/client/play/c_set_title.rs b/pumpkin-protocol/src/client/play/c_set_title.rs index 7a549b904..4e043da0f 100644 --- a/pumpkin-protocol/src/client/play/c_set_title.rs +++ b/pumpkin-protocol/src/client/play/c_set_title.rs @@ -4,12 +4,12 @@ use serde::Serialize; #[derive(Serialize)] #[packet(0x65)] -pub struct CTitleText { - title: TextComponent, +pub struct CTitleText<'a> { + title: TextComponent<'a>, } -impl CTitleText { - pub fn new(title: TextComponent) -> Self { +impl<'a> CTitleText<'a> { + pub fn new(title: TextComponent<'a>) -> Self { Self { title } } } diff --git a/pumpkin-protocol/src/client/play/c_subtitle.rs b/pumpkin-protocol/src/client/play/c_subtitle.rs index 35ebbe50b..10f86d1ef 100644 --- a/pumpkin-protocol/src/client/play/c_subtitle.rs +++ b/pumpkin-protocol/src/client/play/c_subtitle.rs @@ -4,12 +4,12 @@ use serde::Serialize; #[derive(Serialize)] #[packet(0x63)] -pub struct CSubtitle { - subtitle: TextComponent, +pub struct CSubtitle<'a> { + subtitle: TextComponent<'a>, } -impl CSubtitle { - pub fn new(subtitle: TextComponent) -> Self { +impl<'a> CSubtitle<'a> { + pub fn new(subtitle: TextComponent<'a>) -> Self { Self { subtitle } } } diff --git a/pumpkin-protocol/src/client/play/c_system_chat_message.rs b/pumpkin-protocol/src/client/play/c_system_chat_message.rs index d0d2727eb..fd88e622a 100644 --- a/pumpkin-protocol/src/client/play/c_system_chat_message.rs +++ b/pumpkin-protocol/src/client/play/c_system_chat_message.rs @@ -4,13 +4,13 @@ use serde::Serialize; #[derive(Serialize)] #[packet(0x6C)] -pub struct CSystemChatMessge { - content: TextComponent, +pub struct CSystemChatMessge<'a> { + content: TextComponent<'a>, overlay: bool, } -impl CSystemChatMessge { - pub fn new(content: TextComponent, overlay: bool) -> Self { +impl<'a> CSystemChatMessge<'a> { + pub fn new(content: TextComponent<'a>, overlay: bool) -> Self { Self { content, overlay } } } diff --git a/pumpkin-protocol/src/lib.rs b/pumpkin-protocol/src/lib.rs index f0c1a6711..fda17b544 100644 --- a/pumpkin-protocol/src/lib.rs +++ b/pumpkin-protocol/src/lib.rs @@ -1,6 +1,6 @@ use bytebuf::{packet_id::Packet, ByteBuffer, DeserializerError}; use bytes::Buf; -use serde::{Deserialize, Serialize, Serializer}; +use serde::{Deserialize, Serialize}; use std::io::{self, Write}; use thiserror::Error; diff --git a/pumpkin-protocol/src/server/play/s_chat_message.rs b/pumpkin-protocol/src/server/play/s_chat_message.rs index 51d47bd17..bcd7dd91a 100644 --- a/pumpkin-protocol/src/server/play/s_chat_message.rs +++ b/pumpkin-protocol/src/server/play/s_chat_message.rs @@ -2,7 +2,7 @@ use pumpkin_macros::packet; use crate::{ bytebuf::{ByteBuffer, DeserializerError}, - ServerPacket, + ServerPacket, VarInt, }; // derive(Deserialize)] @@ -12,7 +12,7 @@ pub struct SChatMessage { pub timestamp: i64, pub salt: i64, pub signature: Option>, - // pub messagee_count: VarInt, + pub messagee_count: VarInt, // acknowledged: BitSet, } @@ -24,7 +24,7 @@ impl ServerPacket for SChatMessage { timestamp: bytebuf.get_i64(), salt: bytebuf.get_i64(), signature: bytebuf.get_option(|v| v.get_slice().to_vec()), - //messagee_count: bytebuf.get_var_int(), + messagee_count: bytebuf.get_var_int(), }) } } diff --git a/pumpkin-protocol/src/server/play/s_interact.rs b/pumpkin-protocol/src/server/play/s_interact.rs index c141358b9..2ad5b496a 100644 --- a/pumpkin-protocol/src/server/play/s_interact.rs +++ b/pumpkin-protocol/src/server/play/s_interact.rs @@ -1,5 +1,3 @@ -use std::char::MAX; - use num_derive::FromPrimitive; use num_traits::FromPrimitive; use pumpkin_macros::packet; @@ -22,7 +20,7 @@ impl ServerPacket for SInteract { ) -> Result { let entity_id = bytebuf.get_var_int(); let typ = bytebuf.get_var_int(); - let action = ActionType::from_i32(typ.0 as i32).unwrap(); + let action = ActionType::from_i32(typ.0).unwrap(); let target_position: Option<(f32, f32, f32)> = match action { ActionType::Interact => None, ActionType::Attack => None, diff --git a/pumpkin-protocol/src/server/play/s_player_action.rs b/pumpkin-protocol/src/server/play/s_player_action.rs index 4a6061167..a217a2b8f 100644 --- a/pumpkin-protocol/src/server/play/s_player_action.rs +++ b/pumpkin-protocol/src/server/play/s_player_action.rs @@ -3,6 +3,7 @@ use pumpkin_macros::packet; use crate::{position::WorldPosition, VarInt}; #[derive(serde::Deserialize)] +#[allow(dead_code)] #[packet(0x24)] pub struct SPlayerAction { status: VarInt, diff --git a/pumpkin-protocol/src/server/play/s_player_command.rs b/pumpkin-protocol/src/server/play/s_player_command.rs index e62f9cd05..235baa6d5 100644 --- a/pumpkin-protocol/src/server/play/s_player_command.rs +++ b/pumpkin-protocol/src/server/play/s_player_command.rs @@ -1,5 +1,4 @@ use num_derive::FromPrimitive; -use num_traits::FromPrimitive; use pumpkin_macros::packet; use crate::{bytebuf::DeserializerError, ServerPacket, VarInt}; diff --git a/pumpkin-protocol/src/server/play/s_set_creative_slot.rs b/pumpkin-protocol/src/server/play/s_set_creative_slot.rs index 7a2cc4adc..d1a2fbe5a 100644 --- a/pumpkin-protocol/src/server/play/s_set_creative_slot.rs +++ b/pumpkin-protocol/src/server/play/s_set_creative_slot.rs @@ -3,6 +3,7 @@ use pumpkin_macros::packet; use crate::slot::Slot; #[derive(serde::Deserialize, Debug)] +#[allow(dead_code)] #[packet(0x32)] pub struct SSetCreativeSlot { slot: i16, diff --git a/pumpkin-protocol/src/slot.rs b/pumpkin-protocol/src/slot.rs index f6b3d8370..ffefbc03b 100644 --- a/pumpkin-protocol/src/slot.rs +++ b/pumpkin-protocol/src/slot.rs @@ -6,6 +6,7 @@ use serde::{ use crate::VarInt; #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct Slot { item_count: VarInt, item_id: Option, diff --git a/pumpkin-registry/README.md b/pumpkin-registry/README.md index 2202a5d1f..cd0b46392 100644 --- a/pumpkin-registry/README.md +++ b/pumpkin-registry/README.md @@ -1,5 +1,5 @@ ### Pumpkin Registry Here you find all the registry data we have. Registries are repositories of data that contain entries pertaining to certain aspects of the game, such as the world, the player, among others. -Registery data usally send by the Clientbound Registery data Packet. +Registry data usually send by the Clientbound Registry data Packet. A list of Registry entries can be found at https://wiki.vg/Registry_Data \ No newline at end of file diff --git a/pumpkin-registry/src/chat_type.rs b/pumpkin-registry/src/chat_type.rs index 45f324c26..e5d533527 100644 --- a/pumpkin-registry/src/chat_type.rs +++ b/pumpkin-registry/src/chat_type.rs @@ -11,7 +11,7 @@ pub struct ChatType { pub struct Decoration { translation_key: String, #[serde(default, skip_serializing_if = "Option::is_none")] - style: Option