diff --git a/Cargo.toml b/Cargo.toml index dd3e6ba0e..0c92812ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,5 +61,3 @@ uuid = { version = "1.11.0", features = ["serde", "v3", "v4"] } derive_more = { version = "1.0.0", features = ["full"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" - -itertools = "0.13.0" diff --git a/pumpkin-core/Cargo.toml b/pumpkin-core/Cargo.toml index c56368a99..31fd66e52 100644 --- a/pumpkin-core/Cargo.toml +++ b/pumpkin-core/Cargo.toml @@ -13,5 +13,3 @@ num-derive.workspace = true colored = "2" md5 = "0.7.0" - -enum_dispatch = "0.3.13" diff --git a/pumpkin-inventory/Cargo.toml b/pumpkin-inventory/Cargo.toml index ac680e6db..34fb022f1 100644 --- a/pumpkin-inventory/Cargo.toml +++ b/pumpkin-inventory/Cargo.toml @@ -12,8 +12,6 @@ pumpkin-core = { path = "../pumpkin-core" } log.workspace = true rayon.workspace = true -itertools.workspace = true -crossbeam.workspace = true tokio.workspace = true thiserror.workspace = true diff --git a/pumpkin-inventory/src/crafting.rs b/pumpkin-inventory/src/crafting.rs index 61e2a3590..643ffbd36 100644 --- a/pumpkin-inventory/src/crafting.rs +++ b/pumpkin-inventory/src/crafting.rs @@ -1,4 +1,3 @@ -use itertools::Itertools; use pumpkin_registry::{ flatten_3x3, get_tag_values, IngredientSlot, IngredientType, RecipeResult, TagCategory, RECIPES, }; @@ -76,13 +75,13 @@ fn shapeless_crafting_match( input: [[Option; 3]; 3], pattern: &[[[Option; 3]; 3]], ) -> bool { - let mut pattern = pattern + let mut pattern: Vec = pattern .iter() .flatten() .flatten() .flatten() .cloned() - .collect_vec(); + .collect(); for item in input.into_iter().flatten().flatten() { if let Some(index) = pattern.iter().enumerate().find_map(|(i, recipe_item)| { if ingredient_slot_check(recipe_item, item) { diff --git a/pumpkin-inventory/src/drag_handler.rs b/pumpkin-inventory/src/drag_handler.rs index 70336c562..fefcd6059 100644 --- a/pumpkin-inventory/src/drag_handler.rs +++ b/pumpkin-inventory/src/drag_handler.rs @@ -1,6 +1,5 @@ use crate::container_click::MouseDragType; use crate::{Container, InventoryError}; -use itertools::Itertools; use num_traits::Euclid; use pumpkin_world::item::ItemStack; use std::collections::HashMap; @@ -73,10 +72,10 @@ impl DragHandler { Err(InventoryError::MultiplePlayersDragging)? } let mut slots = container.all_slots(); - let slots_cloned = slots + let slots_cloned: Vec> = slots .iter() .map(|stack| stack.map(|item| item.to_owned())) - .collect_vec(); + .collect(); let Some(carried_item) = maybe_carried_item else { return Ok(()); }; diff --git a/pumpkin-macros/Cargo.toml b/pumpkin-macros/Cargo.toml index 233af3bdd..9f2428886 100644 --- a/pumpkin-macros/Cargo.toml +++ b/pumpkin-macros/Cargo.toml @@ -9,7 +9,6 @@ proc-macro = true [dependencies] serde.workspace = true serde_json.workspace = true -itertools.workspace = true proc-macro2 = "1.0" quote = "1.0" diff --git a/pumpkin-protocol/Cargo.toml b/pumpkin-protocol/Cargo.toml index b2a4c7803..3e417ecbb 100644 --- a/pumpkin-protocol/Cargo.toml +++ b/pumpkin-protocol/Cargo.toml @@ -13,7 +13,6 @@ pumpkin-core = { path = "../pumpkin-core" } uuid.workspace = true serde.workspace = true thiserror.workspace = true -itertools.workspace = true log.workspace = true tokio.workspace = true num-traits.workspace = true diff --git a/pumpkin-protocol/src/client/play/c_chunk_data.rs b/pumpkin-protocol/src/client/play/c_chunk_data.rs index cd98d1cf0..919dcc2fc 100644 --- a/pumpkin-protocol/src/client/play/c_chunk_data.rs +++ b/pumpkin-protocol/src/client/play/c_chunk_data.rs @@ -1,5 +1,4 @@ use crate::{bytebuf::ByteBuffer, BitSet, ClientPacket, VarInt}; -use itertools::Itertools; use pumpkin_macros::client_packet; use pumpkin_world::{chunk::ChunkData, DIRECT_PALETTE_BITS}; @@ -26,7 +25,7 @@ impl ClientPacket for CChunkData<'_> { data_buf.put_i16(block_count); //// Block states - let palette = chunk.iter().dedup().collect_vec(); + let palette = chunk; // TODO: make dynamic block_size work // TODO: make direct block_size work enum PaletteType { @@ -55,7 +54,7 @@ impl ClientPacket for CChunkData<'_> { palette.iter().for_each(|id| { // Palette - data_buf.put_var_int(&VarInt(**id as i32)); + data_buf.put_var_int(&VarInt(*id as i32)); }); // Data array length let data_array_len = chunk.len().div_ceil(64 / block_size as usize); @@ -67,7 +66,7 @@ impl ClientPacket for CChunkData<'_> { for block in block_clump.iter().rev() { let index = palette .iter() - .position(|b| *b == block) + .position(|b| b == block) .expect("Its just got added, ofc it should be there"); out_long = out_long << block_size | (index as i64); } diff --git a/pumpkin-registry/Cargo.toml b/pumpkin-registry/Cargo.toml index 3d55b6bb7..a90646d70 100644 --- a/pumpkin-registry/Cargo.toml +++ b/pumpkin-registry/Cargo.toml @@ -13,9 +13,3 @@ indexmap = { version = "2.7.0", features = ["serde"] } serde.workspace = true serde_json.workspace = true -rayon.workspace = true - -num-traits.workspace = true -num-derive.workspace = true - -itertools.workspace = true diff --git a/pumpkin-registry/src/recipe/recipe_formats.rs b/pumpkin-registry/src/recipe/recipe_formats.rs index 7c26376a0..5726c2824 100644 --- a/pumpkin-registry/src/recipe/recipe_formats.rs +++ b/pumpkin-registry/src/recipe/recipe_formats.rs @@ -2,8 +2,6 @@ use super::super::recipe::RecipeType; use super::read::{ ingredients::IngredientSlot, CraftingType, RecipeKeys, RecipeResult, RecipeTrait, }; -use itertools::Itertools; - pub struct ShapedCrafting { keys: RecipeKeys, pattern: [[Option; 3]; 3], @@ -85,7 +83,7 @@ impl RecipeTrait for ShapelessCrafting { [v1, v2, v3] }) - .collect_vec() + .collect() } fn result(self) -> RecipeResult { diff --git a/pumpkin-world/Cargo.toml b/pumpkin-world/Cargo.toml index 18745f731..fcbc14a55 100644 --- a/pumpkin-world/Cargo.toml +++ b/pumpkin-world/Cargo.toml @@ -11,24 +11,20 @@ pumpkin-macros = { path = "../pumpkin-macros" } tokio.workspace = true rayon.workspace = true derive_more.workspace = true -itertools.workspace = true thiserror.workspace = true serde.workspace = true serde_json.workspace = true log.workspace = true -parking_lot.workspace = true num-traits.workspace = true num-derive.workspace = true -futures = "0.3" dashmap = "6.1.0" -# Compression +# Compression flate2 = "1.0" lz4 = "1.28.0" enum_dispatch = "0.3.13" -derive-getters = "0.5.0" fastnbt = { git = "https://github.com/owengage/fastnbt.git" } @@ -39,7 +35,6 @@ rand = "0.8.5" [dev-dependencies] criterion = { version = "0.5.1", features = ["html_reports"] } - [[bench]] name = "chunk_noise" harness = false diff --git a/pumpkin-world/src/chunk/anvil.rs b/pumpkin-world/src/chunk/anvil.rs index c97142ac4..86389be65 100644 --- a/pumpkin-world/src/chunk/anvil.rs +++ b/pumpkin-world/src/chunk/anvil.rs @@ -4,7 +4,6 @@ use std::{ }; use flate2::bufread::{GzDecoder, ZlibDecoder}; -use itertools::Itertools; use crate::level::SaveFile; @@ -143,7 +142,7 @@ impl ChunkReader for AnvilChunkReader { }; // TODO: check checksum to make sure chunk is not corrupted - let header = file_buf.drain(0..5).collect_vec(); + let header: Vec = file_buf.drain(0..5).collect(); let compression = Compression::from_byte(header[4]).ok_or( ChunkReadingError::Compression(CompressionError::UnknownCompression), @@ -152,7 +151,7 @@ impl ChunkReader for AnvilChunkReader { let size = u32::from_be_bytes(header[..4].try_into().unwrap()); // size includes the compression scheme byte, so we need to subtract 1 - let chunk_data = file_buf.drain(0..size as usize - 1).collect_vec(); + let chunk_data = file_buf.drain(0..size as usize - 1).collect(); let decompressed_chunk = compression .decompress_data(chunk_data) .map_err(ChunkReadingError::Compression)?; diff --git a/pumpkin-world/src/cylindrical_chunk_iterator.rs b/pumpkin-world/src/cylindrical_chunk_iterator.rs index 67d1f498e..7e3882613 100644 --- a/pumpkin-world/src/cylindrical_chunk_iterator.rs +++ b/pumpkin-world/src/cylindrical_chunk_iterator.rs @@ -1,4 +1,3 @@ -use itertools::Itertools; use pumpkin_core::math::vector2::Vector2; #[derive(Debug, Clone, Copy, PartialEq)] @@ -76,7 +75,7 @@ impl Cylindrical { all_chunks .into_iter() .filter(|chunk| self.is_within_distance(chunk.x, chunk.z)) - .collect_vec() + .collect() } } diff --git a/pumpkin-world/src/world_gen/noise/density/spline.rs b/pumpkin-world/src/world_gen/noise/density/spline.rs index 9f4698188..cb2aa6eed 100644 --- a/pumpkin-world/src/world_gen/noise/density/spline.rs +++ b/pumpkin-world/src/world_gen/noise/density/spline.rs @@ -1,7 +1,6 @@ use std::{marker::PhantomData, sync::Arc}; use enum_dispatch::enum_dispatch; -use itertools::Itertools; use crate::world_gen::noise::lerp; @@ -302,13 +301,13 @@ impl> MutableSpline = converted_points .into_iter() .map(|point| match point { SplinePoint::Immutable(point) => point, _ => unreachable!(), }) - .collect_vec(); + .collect(); SplineRef::Immutable( ImmutableSpline { function: shared, @@ -387,7 +386,7 @@ impl> MutableSplineImpl< let converted_points = points .into_iter() .map(|point| point.convert(converter)) - .collect_vec(); + .collect(); Self::create_new_spline(converted_base, converted_points) } @@ -398,7 +397,7 @@ impl> MutableSplineImpl< .points .iter() .map(|point| point.clone_to_new_point()) - .collect_vec(); + .collect(); Self::create_new_spline(cloned_function, cloned_points) } @@ -462,18 +461,18 @@ impl ImmutableSplineRef { converter: &mut dyn ConverterImpl, ) -> Option> { let converted_base = self.0.function.maybe_convert(converter); - let maybe_converted_points = self + let maybe_converted_points: Vec>> = self .0 .points .iter() .map(|point| point.maybe_convert(converter)) - .collect_vec(); + .collect(); if converted_base.is_none() && maybe_converted_points.iter().all(|point| point.is_none()) { None } else { let converted_base = converted_base.unwrap_or_else(|| self.0.function.clone().into()); - let converted_points = maybe_converted_points + let converted_points: Vec> = maybe_converted_points .into_iter() .enumerate() .map(|(index, point)| { @@ -483,7 +482,7 @@ impl ImmutableSplineRef { self.0.points[index].clone().into() } }) - .collect_vec(); + .collect(); Some(match converted_base { ComponentReferenceImplementation::Shared(shared) => { @@ -491,13 +490,13 @@ impl ImmutableSplineRef { .iter() .all(|point| matches!(point, SplinePoint::Immutable(_))) { - let immutable_points = converted_points + let immutable_points: Vec = converted_points .into_iter() .map(|point| match point { SplinePoint::Immutable(point) => point, _ => unreachable!(), }) - .collect_vec(); + .collect(); SplineRef::Immutable( ImmutableSpline { function: shared, diff --git a/pumpkin-world/src/world_gen/noise/perlin.rs b/pumpkin-world/src/world_gen/noise/perlin.rs index 4faf760f4..09563485c 100644 --- a/pumpkin-world/src/world_gen/noise/perlin.rs +++ b/pumpkin-world/src/world_gen/noise/perlin.rs @@ -1,6 +1,5 @@ use std::sync::Arc; -use itertools::{izip, Itertools}; use num_traits::Pow; use pumpkin_core::random::RandomGenerator; @@ -226,19 +225,6 @@ impl OctavePerlinNoiseSampler { random.skip(262); } } - - #[cfg(debug_assertions)] - { - use itertools::Itertools; - use num_traits::Zero; - - if let Ok(length1) = samplers.iter().filter(|x| x.is_some()).try_len() { - if let Ok(length2) = amplitudes.iter().filter(|x| !x.is_zero()).try_len() { - assert_eq!(length1, length2); - } - } - assert!(j >= i as i32 - 1); - } } else { let splitter = random.next_splitter(); for k in 0..i { @@ -256,20 +242,20 @@ impl OctavePerlinNoiseSampler { let mut lacunarity = 2f64.pow((-j) as f64); let max_value = Self::get_total_amplitude(2f64, persistence, amplitudes); - let persistences = (0..amplitudes.len()) + let persistences: Vec = (0..amplitudes.len()) .map(|_| { let result = persistence; persistence /= 2f64; result }) - .collect_vec(); - let lacunarities = (0..amplitudes.len()) + .collect(); + let lacunarities: Vec = (0..amplitudes.len()) .map(|_| { let result = lacunarity; lacunarity *= 2f64; result }) - .collect_vec(); + .collect(); Self { octave_samplers: samplers.into(), @@ -284,13 +270,13 @@ impl OctavePerlinNoiseSampler { pub fn sample(&self, x: f64, y: f64, z: f64) -> f64 { let mut d = 0f64; - for (sampler, amplitude, persistence, lacunarity) in izip!( - &self.octave_samplers, - &self.amplitudes, - &self.persistences, - &self.lacunarities - ) { - if let Some(sampler) = sampler { + let num_octaves = self.octave_samplers.len(); + for i in 0..num_octaves { + if let Some(sampler) = &self.octave_samplers[i] { + let lacunarity = self.lacunarities[i]; + let amplitude = self.amplitudes[i]; + let persistence = self.persistences[i]; + let g = sampler.sample_no_fade( Self::maintain_precision(x * lacunarity), Self::maintain_precision(y * lacunarity), diff --git a/pumpkin-world/src/world_gen/proto_chunk.rs b/pumpkin-world/src/world_gen/proto_chunk.rs index aceefc188..6f36cab6c 100644 --- a/pumpkin-world/src/world_gen/proto_chunk.rs +++ b/pumpkin-world/src/world_gen/proto_chunk.rs @@ -216,7 +216,6 @@ impl ProtoChunk { mod test { use std::{fs, path::Path}; - use itertools::Itertools; use pumpkin_core::math::vector2::Vector2; use crate::read_data_from_file; @@ -235,7 +234,7 @@ mod test { .flat_block_map .into_iter() .map(|state| state.state_id) - .collect_vec() + .collect::>() ); } @@ -252,7 +251,7 @@ mod test { .flat_block_map .into_iter() .map(|state| state.state_id) - .collect_vec() + .collect::>() ); } } diff --git a/pumpkin/Cargo.toml b/pumpkin/Cargo.toml index 38bd71902..a3f4a14ea 100644 --- a/pumpkin/Cargo.toml +++ b/pumpkin/Cargo.toml @@ -21,7 +21,6 @@ pumpkin-protocol = { path = "../pumpkin-protocol" } pumpkin-registry = { path = "../pumpkin-registry" } pumpkin-macros = { path = "../pumpkin-macros" } -itertools.workspace = true log.workspace = true crossbeam.workspace = true uuid.workspace = true @@ -31,7 +30,6 @@ thiserror.workspace = true num-traits.workspace = true num-derive.workspace = true -parking_lot.workspace = true # config serde.workspace = true @@ -56,14 +54,14 @@ reqwest = { version = "0.12.9", default-features = false, features = [ ] } sha1 = "0.10.6" -digest = "=0.11.0-pre.9" # velocity en hmac = "0.12.1" sha2 = "0.10.8" -# icon loading base64 = "0.22.1" + +# icon loading png = "0.17.15" # logging diff --git a/pumpkin/src/client/container.rs b/pumpkin/src/client/container.rs index e89026380..11a5c8549 100644 --- a/pumpkin/src/client/container.rs +++ b/pumpkin/src/client/container.rs @@ -1,6 +1,5 @@ use crate::entity::player::Player; use crate::server::Server; -use itertools::Itertools; use pumpkin_core::text::TextComponent; use pumpkin_core::GameMode; use pumpkin_inventory::container_click::{ @@ -59,11 +58,11 @@ impl Player { let container = OptionallyCombinedContainer::new(&mut inventory, container); - let slots = container + let slots: Vec = container .all_slots_ref() .into_iter() .map(Slot::from) - .collect_vec(); + .collect(); let carried_item = self .carried_item @@ -462,7 +461,7 @@ impl Player { } async fn get_current_players_in_container(&self, server: &Server) -> Vec> { - let player_ids = { + let player_ids: Vec = { let open_containers = server.open_containers.read().await; open_containers .get(&self.open_container.load().unwrap()) @@ -470,7 +469,7 @@ impl Player { .all_player_ids() .into_iter() .filter(|player_id| *player_id != self.entity_id()) - .collect_vec() + .collect() }; let player_token = self.gameprofile.id; @@ -493,7 +492,7 @@ impl Player { player_ids.contains(&entity_id).then(|| player.clone()) } }) - .collect_vec(); + .collect(); players } diff --git a/pumpkin/src/command/commands/cmd_list.rs b/pumpkin/src/command/commands/cmd_list.rs index fe1b4e0c7..5a81f8f96 100644 --- a/pumpkin/src/command/commands/cmd_list.rs +++ b/pumpkin/src/command/commands/cmd_list.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use async_trait::async_trait; -use itertools::Itertools; use pumpkin_config::BASIC_CONFIG; use pumpkin_core::text::TextComponent; @@ -35,10 +34,7 @@ impl CommandExecutor for ListExecutor { "There are {} of a max of {} players online: {}", players.len(), BASIC_CONFIG.max_players, - players - .iter() - .map(|player| &player.gameprofile.name) - .join(", ") + get_player_names(players) ) }; @@ -48,6 +44,17 @@ impl CommandExecutor for ListExecutor { } } +fn get_player_names(players: Vec>) -> String { + let mut names = String::new(); + for player in players { + if !names.is_empty() { + names.push_str(", "); + } + names.push_str(&player.gameprofile.name); + } + names +} + pub fn init_command_tree<'a>() -> CommandTree<'a> { CommandTree::new(NAMES, DESCRIPTION).execute(&ListExecutor) } diff --git a/pumpkin/src/world/mod.rs b/pumpkin/src/world/mod.rs index 282dab5f4..0f9b5bb92 100644 --- a/pumpkin/src/world/mod.rs +++ b/pumpkin/src/world/mod.rs @@ -9,7 +9,6 @@ use crate::{ error::PumpkinError, server::Server, }; -use itertools::Itertools; use level_time::LevelTime; use pumpkin_config::BasicConfiguration; use pumpkin_core::math::vector2::Vector2; @@ -224,11 +223,7 @@ impl World { server: &Server, ) { let command_dispatcher = &server.command_dispatcher; - let dimensions = &server - .dimensions - .iter() - .map(DimensionType::name) - .collect_vec(); + let dimensions: Vec<&str> = server.dimensions.iter().map(DimensionType::name).collect(); // This code follows the vanilla packet order let entity_id = player.entity_id(); @@ -245,7 +240,7 @@ impl World { .send_packet(&CLogin::new( entity_id, base_config.hardcore, - dimensions, + &dimensions, base_config.max_players.into(), base_config.view_distance.into(), // TODO: view distance base_config.simulation_distance.into(), // TODO: sim view dinstance