From 4bccba7b201d176f1443937db8aff2b276eeed17 Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Thu, 10 Apr 2025 21:21:43 +0200 Subject: [PATCH] fix some typos - also moved tempfile dep to dev-dependencies - removed the noise crate - renamed some things --- pumpkin-data/build/block.rs | 2 +- pumpkin-data/build/noise_router.rs | 2 +- pumpkin-inventory/src/lib.rs | 5 +- pumpkin-inventory/src/open_container.rs | 12 ++-- pumpkin-nbt/Cargo.toml | 4 +- .../src/client/play/chunk_data.rs | 56 ++++++++++--------- pumpkin-protocol/src/ser/deserializer.rs | 10 +--- pumpkin-world/Cargo.toml | 2 - pumpkin-world/benches/chunk_io.rs | 2 +- pumpkin-world/src/chunk/format/anvil.rs | 6 +- .../noise_router/chunk_density_function.rs | 2 +- pumpkin-world/src/item/mod.rs | 4 +- pumpkin/Cargo.toml | 6 +- pumpkin/src/block/blocks/cactus.rs | 3 +- pumpkin/src/block/blocks/sugar_cane.rs | 6 +- pumpkin/src/command/args/position_2d.rs | 2 +- pumpkin/src/command/tree/builder.rs | 2 +- pumpkin/src/entity/player.rs | 4 +- pumpkin/src/lib.rs | 2 +- pumpkin/src/net/authentication.rs | 6 +- pumpkin/src/net/container.rs | 6 +- pumpkin/src/net/mod.rs | 2 +- pumpkin/src/net/proxy/velocity.rs | 2 +- pumpkin/src/server/mod.rs | 22 ++++---- pumpkin/src/server/seasonal_events.rs | 2 +- pumpkin/src/world/explosion.rs | 6 +- pumpkin/src/world/mod.rs | 10 ++-- 27 files changed, 93 insertions(+), 95 deletions(-) diff --git a/pumpkin-data/build/block.rs b/pumpkin-data/build/block.rs index 72e068398..326711657 100644 --- a/pumpkin-data/build/block.rs +++ b/pumpkin-data/build/block.rs @@ -959,7 +959,7 @@ pub(crate) fn build() -> TokenStream { property_enum: renamed_property.clone(), }); - // If this property doesnt have an `enum` yet, make one. + // If this property doesn't have an `enum` yet, make one. let _ = property_enums .entry(renamed_property.clone()) .or_insert_with(|| PropertyStruct { diff --git a/pumpkin-data/build/noise_router.rs b/pumpkin-data/build/noise_router.rs index 5f9e0c040..ac5bc7196 100644 --- a/pumpkin-data/build/noise_router.rs +++ b/pumpkin-data/build/noise_router.rs @@ -920,7 +920,7 @@ impl NoiseRouterRepr { .vein_gap .get_index_for_component(&mut noise_component_stack, &mut noise_lookup_map); - // These should all be cached so it doesnt matter where their components are + // These should all be cached so it doesn't matter where their components are let noise_erosion = self .erosion .clone() diff --git a/pumpkin-inventory/src/lib.rs b/pumpkin-inventory/src/lib.rs index ccdd10d8c..2642d1fc3 100644 --- a/pumpkin-inventory/src/lib.rs +++ b/pumpkin-inventory/src/lib.rs @@ -250,15 +250,14 @@ impl<'a> Container for OptionallyCombinedContainer<'a, 'a> { } fn all_slots(&mut self) -> Box<[&mut Option]> { - let slots = match &mut self.container { + match &mut self.container { Some(container) => { let mut slots = container.all_slots().into_vec(); slots.extend(self.inventory.all_combinable_slots_mut()); slots.into_boxed_slice() } None => self.inventory.all_slots(), - }; - slots + } } fn all_slots_ref(&self) -> Box<[Option<&ItemStack>]> { diff --git a/pumpkin-inventory/src/open_container.rs b/pumpkin-inventory/src/open_container.rs index e40b639ae..3949f727f 100644 --- a/pumpkin-inventory/src/open_container.rs +++ b/pumpkin-inventory/src/open_container.rs @@ -136,20 +136,20 @@ impl Container for CraftingTable { } fn all_slots(&mut self) -> Box<[&mut Option]> { let slots = vec![&mut self.output]; - let slots = slots + + slots .into_iter() .chain(self.input.iter_mut().flatten()) - .collect(); - slots + .collect() } fn all_slots_ref(&self) -> Box<[Option<&ItemStack>]> { let slots = vec![self.output.as_ref()]; - let slots = slots + + slots .into_iter() .chain(self.input.iter().flatten().map(|i| i.as_ref())) - .collect(); - slots + .collect() } fn all_combinable_slots(&self) -> Box<[Option<&ItemStack>]> { diff --git a/pumpkin-nbt/Cargo.toml b/pumpkin-nbt/Cargo.toml index f85452a21..eb51cbf7f 100644 --- a/pumpkin-nbt/Cargo.toml +++ b/pumpkin-nbt/Cargo.toml @@ -7,7 +7,9 @@ edition.workspace = true serde.workspace = true thiserror.workspace = true bytes.workspace = true -tempfile.workspace = true cesu8 = "1.1" flate2 = "1.1" + +[dev-dependencies] +tempfile.workspace = true diff --git a/pumpkin-protocol/src/client/play/chunk_data.rs b/pumpkin-protocol/src/client/play/chunk_data.rs index f8b1d4506..efa8b27f5 100644 --- a/pumpkin-protocol/src/client/play/chunk_data.rs +++ b/pumpkin-protocol/src/client/play/chunk_data.rs @@ -41,7 +41,7 @@ impl ClientPacket for CChunkData<'_> { write.write_i64_be(*mb)?; } - let mut data_buf = Vec::new(); + let mut blocks_and_biomes_buf = Vec::new(); let mut sky_light_buf = Vec::new(); let mut sky_light_empty_mask = 0; @@ -79,50 +79,52 @@ impl ClientPacket for CChunkData<'_> { // Block count let non_empty_block_count = section.block_states.non_air_block_count() as i16; - data_buf.write_i16_be(non_empty_block_count)?; + blocks_and_biomes_buf.write_i16_be(non_empty_block_count)?; // This is a bit messy, but we dont have access to VarInt in pumpkin-world let network_repr = section.block_states.convert_network(); - data_buf.write_u8_be(network_repr.bits_per_entry)?; + blocks_and_biomes_buf.write_u8_be(network_repr.bits_per_entry)?; match network_repr.palette { NetworkPalette::Single(registry_id) => { - data_buf.write_var_int(®istry_id.into())?; + blocks_and_biomes_buf.write_var_int(®istry_id.into())?; } NetworkPalette::Indirect(palette) => { - data_buf.write_var_int(&palette.len().try_into().map_err(|_| { - WritingError::Message(format!( - "{} is not representable as a VarInt!", - palette.len() - )) - })?)?; + blocks_and_biomes_buf.write_var_int(&palette.len().try_into().map_err( + |_| { + WritingError::Message(format!( + "{} is not representable as a VarInt!", + palette.len() + )) + }, + )?)?; for registry_id in palette { - data_buf.write_var_int(®istry_id.into())?; + blocks_and_biomes_buf.write_var_int(®istry_id.into())?; } } NetworkPalette::Direct => {} } - // NOTE: Not updated in wiki; i64 array length is now determined by the bits per entry - //data_buf.write_var_int(&network_repr.packed_data.len().into())?; for packed in network_repr.packed_data { - data_buf.write_i64_be(packed)?; + blocks_and_biomes_buf.write_i64_be(packed)?; } let network_repr = section.biomes.convert_network(); - data_buf.write_u8_be(network_repr.bits_per_entry)?; + blocks_and_biomes_buf.write_u8_be(network_repr.bits_per_entry)?; match network_repr.palette { NetworkPalette::Single(registry_id) => { - data_buf.write_var_int(®istry_id.into())?; + blocks_and_biomes_buf.write_var_int(®istry_id.into())?; } NetworkPalette::Indirect(palette) => { - data_buf.write_var_int(&palette.len().try_into().map_err(|_| { - WritingError::Message(format!( - "{} is not representable as a VarInt!", - palette.len() - )) - })?)?; + blocks_and_biomes_buf.write_var_int(&palette.len().try_into().map_err( + |_| { + WritingError::Message(format!( + "{} is not representable as a VarInt!", + palette.len() + )) + }, + )?)?; for registry_id in palette { - data_buf.write_var_int(®istry_id.into())?; + blocks_and_biomes_buf.write_var_int(®istry_id.into())?; } } NetworkPalette::Direct => {} @@ -131,18 +133,18 @@ impl ClientPacket for CChunkData<'_> { // NOTE: Not updated in wiki; i64 array length is now determined by the bits per entry //data_buf.write_var_int(&network_repr.packed_data.len().into())?; for packed in network_repr.packed_data { - data_buf.write_i64_be(packed)?; + blocks_and_biomes_buf.write_i64_be(packed)?; } } // Chunk data - write.write_var_int(&data_buf.len().try_into().map_err(|_| { + write.write_var_int(&blocks_and_biomes_buf.len().try_into().map_err(|_| { WritingError::Message(format!( "{} is not representable as a VarInt!", - data_buf.len() + blocks_and_biomes_buf.len() )) })?)?; - write.write_slice(&data_buf)?; + write.write_slice(&blocks_and_biomes_buf)?; // TODO: block entities write.write_var_int(&VarInt(0))?; diff --git a/pumpkin-protocol/src/ser/deserializer.rs b/pumpkin-protocol/src/ser/deserializer.rs index aa43b12ed..ee995a764 100644 --- a/pumpkin-protocol/src/ser/deserializer.rs +++ b/pumpkin-protocol/src/ser/deserializer.rs @@ -205,9 +205,7 @@ impl<'de, R: Read> de::Deserializer<'de> for &mut Deserializer { } } - let value = visitor.visit_seq(Access { deserializer: self }); - - value + visitor.visit_seq(Access { deserializer: self }) } fn deserialize_tuple(self, len: usize, visitor: V) -> Result @@ -236,12 +234,10 @@ impl<'de, R: Read> de::Deserializer<'de> for &mut Deserializer { } } - let value = visitor.visit_seq(Access { + visitor.visit_seq(Access { deserializer: self, len, - }); - - value + }) } fn deserialize_tuple_struct( diff --git a/pumpkin-world/Cargo.toml b/pumpkin-world/Cargo.toml index a13d9e47b..290c4da43 100644 --- a/pumpkin-world/Cargo.toml +++ b/pumpkin-world/Cargo.toml @@ -19,7 +19,6 @@ bytes.workspace = true tokio.workspace = true rayon.workspace = true -derive_more.workspace = true uuid.workspace = true thiserror.workspace = true serde.workspace = true @@ -42,7 +41,6 @@ itertools = "0.14.0" file-guard = "0.2" indexmap = "2.9" enum_dispatch = "0.3" -noise = "0.9" derive-getters = "0.5.0" thread_local = "1.1.8" diff --git a/pumpkin-world/benches/chunk_io.rs b/pumpkin-world/benches/chunk_io.rs index 5d08b50e8..cd80bd87e 100644 --- a/pumpkin-world/benches/chunk_io.rs +++ b/pumpkin-world/benches/chunk_io.rs @@ -108,7 +108,7 @@ fn initialize_level( /* // This doesn't really test anything... fn bench_chunk_io_parallel(c: &mut Criterion) { - // System temp dirs are in-memory, so we cant use temp_dir + // System temp dirs are in-memory, so we can't use temp_dir let root_dir = global_path!("./bench_root_tmp"); let _ = fs::remove_dir_all(&root_dir); // delete if it exists fs::create_dir(&root_dir).unwrap(); // create the directory diff --git a/pumpkin-world/src/chunk/format/anvil.rs b/pumpkin-world/src/chunk/format/anvil.rs index 33c910441..83341d328 100644 --- a/pumpkin-world/src/chunk/format/anvil.rs +++ b/pumpkin-world/src/chunk/format/anvil.rs @@ -326,7 +326,7 @@ impl AnvilChunkData { let compression = compression .unwrap_or_else(|| advanced_config().chunk.compression.algorithm.clone().into()); - // We need to buffer here anyway so theres no use in making an impl Write for this + // We need to buffer here anyway so there's no use in making an impl Write for this let compressed_data = compression .compress_data(&raw_bytes, advanced_config().chunk.compression.level) .map_err(ChunkWritingError::Compression)?; @@ -675,7 +675,7 @@ impl ChunkSerializer for AnvilChunkFile { }); write_action.maybe_update_chunk_index(index); } else { - // Walk back the end of the list; seeing if theres something that can fit + // Walk back the end of the list; seeing if there's something that can fit // in our spot. Here we play a game between is it worth it to do all // this swapping. I figure if we don't find it after 64 chunks, just // re-write the whole file instead @@ -772,7 +772,7 @@ impl ChunkSerializer for AnvilChunkFile { } // If the shift is negative then there will be trailing data, but i - // think thats fine + // think that's fine let new_end = self.end_sector as i64 + offset; self.end_sector = new_end as u32; diff --git a/pumpkin-world/src/generation/noise_router/chunk_density_function.rs b/pumpkin-world/src/generation/noise_router/chunk_density_function.rs index eb08b399c..6aede4d55 100644 --- a/pumpkin-world/src/generation/noise_router/chunk_density_function.rs +++ b/pumpkin-world/src/generation/noise_router/chunk_density_function.rs @@ -413,7 +413,7 @@ impl Cache2D { pub fn new(input_index: usize, min_value: f64, max_value: f64) -> Self { Self { input_index, - // I know this is because theres is definitely world coords that are this marker, but this + // I know this is because there's is definitely world coords that are this marker, but this // is how vanilla does it, so I'm going to for pairity last_sample_column: chunk_pos::MARKER, last_sample_result: Default::default(), diff --git a/pumpkin-world/src/item/mod.rs b/pumpkin-world/src/item/mod.rs index d39433921..afb4465bc 100644 --- a/pumpkin-world/src/item/mod.rs +++ b/pumpkin-world/src/item/mod.rs @@ -57,7 +57,7 @@ impl ItemStack { if let Some(blocks) = get_tag_values(RegistryKey::Block, entry.strip_prefix('#').unwrap()) { - if blocks.iter().any(|s| *s == block) { + if blocks.contains(&block) { return speed; } } @@ -92,7 +92,7 @@ impl ItemStack { if let Some(blocks) = get_tag_values(RegistryKey::Block, entry.strip_prefix('#').unwrap()) { - if blocks.iter().any(|s| *s == block) { + if blocks.contains(&block) { return correct_for_drops; } } diff --git a/pumpkin/Cargo.toml b/pumpkin/Cargo.toml index 27b78ce06..27d3ef4db 100644 --- a/pumpkin/Cargo.toml +++ b/pumpkin/Cargo.toml @@ -39,8 +39,6 @@ async-trait.workspace = true serde.workspace = true serde_json.workspace = true -tempfile.workspace = true - bytes.workspace = true rand = "0.8" @@ -94,6 +92,10 @@ dhat = { version = "0.3.3", optional = true } [build-dependencies] git-version = "0.3" + +[dev-dependencies] +tempfile.workspace = true + # This makes it so the entire project doesn't recompile on each build on linux. [target.'cfg(target_os = "windows")'.build-dependencies] tauri-winres = "0.3" diff --git a/pumpkin/src/block/blocks/cactus.rs b/pumpkin/src/block/blocks/cactus.rs index 9fe325792..fba42179e 100644 --- a/pumpkin/src/block/blocks/cactus.rs +++ b/pumpkin/src/block/blocks/cactus.rs @@ -4,6 +4,7 @@ use async_trait::async_trait; use pumpkin_data::block::{ Block, BlockProperties, CactusLikeProperties, EnumVariants, Integer0To15, }; +use pumpkin_data::tag::Tagable; use pumpkin_macros::pumpkin_block; use pumpkin_world::block::BlockDirection; use pumpkin_world::chunk::TickPriority; @@ -85,7 +86,7 @@ impl PumpkinBlock for CactusBlock { } let block = world.get_block(&pos.down()).await.unwrap(); // TODO: use tags - (block == Block::CACTUS || block == Block::SAND) + (block == Block::CACTUS || block.is_tagged_with("minecraft:sand").unwrap()) && !world.get_block_state(&pos.up()).await.unwrap().is_liquid } } diff --git a/pumpkin/src/block/blocks/sugar_cane.rs b/pumpkin/src/block/blocks/sugar_cane.rs index 18f89065d..f3d2d23c1 100644 --- a/pumpkin/src/block/blocks/sugar_cane.rs +++ b/pumpkin/src/block/blocks/sugar_cane.rs @@ -4,6 +4,7 @@ use async_trait::async_trait; use pumpkin_data::block::{ Block, BlockProperties, CactusLikeProperties, EnumVariants, Integer0To15, }; +use pumpkin_data::tag::Tagable; use pumpkin_macros::pumpkin_block; use pumpkin_world::block::BlockDirection; use pumpkin_world::chunk::TickPriority; @@ -78,8 +79,9 @@ impl PumpkinBlock for SugarCaneBlock { return true; } - // TODO: use tags - if block == Block::DIRT || block == Block::SAND { + if block.is_tagged_with("minecraft:dirt").unwrap() + || block.is_tagged_with("minecraft:sand").unwrap() + { for direction in BlockDirection::horizontal() { let block = world .get_block(&pos.down().offset(direction.to_offset())) diff --git a/pumpkin/src/command/args/position_2d.rs b/pumpkin/src/command/args/position_2d.rs index da9deb7ce..7ab4046c4 100644 --- a/pumpkin/src/command/args/position_2d.rs +++ b/pumpkin/src/command/args/position_2d.rs @@ -14,7 +14,7 @@ use super::{Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser}; /// x and z coordinates only /// -/// todo: implememnt ~ ^ notations +/// todo: implement ~ ^ notations pub struct Position2DArgumentConsumer; impl GetClientSideArgParser for Position2DArgumentConsumer { diff --git a/pumpkin/src/command/tree/builder.rs b/pumpkin/src/command/tree/builder.rs index 4682d60fe..c1095a7c0 100644 --- a/pumpkin/src/command/tree/builder.rs +++ b/pumpkin/src/command/tree/builder.rs @@ -127,7 +127,7 @@ impl NonLeafNodeBuilder { } } -/// Matches a sting literal. +/// Matches a string literal. #[must_use] pub fn literal(string: impl Into) -> NonLeafNodeBuilder { NonLeafNodeBuilder { diff --git a/pumpkin/src/entity/player.rs b/pumpkin/src/entity/player.rs index 8a226654f..4dea1cf75 100644 --- a/pumpkin/src/entity/player.rs +++ b/pumpkin/src/entity/player.rs @@ -493,7 +493,7 @@ impl Player { offset: Vector3, max_speed: f32, particle_count: i32, - pariticle: Particle, + particle: Particle, ) { self.client .enqueue_packet(&CParticle::new( @@ -503,7 +503,7 @@ impl Player { offset, max_speed, particle_count, - VarInt(pariticle as i32), + VarInt(particle as i32), &[], )) .await; diff --git a/pumpkin/src/lib.rs b/pumpkin/src/lib.rs index dbf718300..b585f2340 100644 --- a/pumpkin/src/lib.rs +++ b/pumpkin/src/lib.rs @@ -287,7 +287,7 @@ impl PumpkinServer { } else { format!("{client_addr}") }; - log::info!( + log::debug!( "Accepted connection from: {} (id {})", formatted_address, id diff --git a/pumpkin/src/net/authentication.rs b/pumpkin/src/net/authentication.rs index 2fb595787..8e2588946 100644 --- a/pumpkin/src/net/authentication.rs +++ b/pumpkin/src/net/authentication.rs @@ -31,17 +31,15 @@ pub struct Texture { } #[derive(Deserialize, Clone, Debug)] +#[serde(rename_all = "camelCase")] pub struct JsonPublicKey { - #[serde(rename = "publicKey")] pub public_key: String, } #[derive(Deserialize, Clone, Debug)] +#[serde(rename_all = "camelCase")] pub struct MojangPublicKeys { - #[serde(rename = "profilePropertyKeys")] pub profile_property_keys: Vec, - #[serde(rename = "playerCertificateKeys")] pub player_certificate_keys: Vec, - #[serde(rename = "authenticationKeys")] pub authentication_keys: Option>, } diff --git a/pumpkin/src/net/container.rs b/pumpkin/src/net/container.rs index c4f859504..e34f7161e 100644 --- a/pumpkin/src/net/container.rs +++ b/pumpkin/src/net/container.rs @@ -600,8 +600,7 @@ impl Player { // TODO: Figure out better way to get only the players from player_ids // Also refactor out a better method to get individual advanced state ids - let players = self - .living_entity + self.living_entity .entity .world .read() @@ -618,8 +617,7 @@ impl Player { player_ids.contains(&entity_id).then(|| player.clone()) } }) - .collect(); - players + .collect() } pub async fn send_container_changes( diff --git a/pumpkin/src/net/mod.rs b/pumpkin/src/net/mod.rs index 0b71a2585..ddf4c432d 100644 --- a/pumpkin/src/net/mod.rs +++ b/pumpkin/src/net/mod.rs @@ -621,7 +621,7 @@ impl Client { pub async fn kick(&self, reason: TextComponent) { match self.connection_state.load() { ConnectionState::Login => { - // TextComponent implements Serialze and writes in bytes instead of String, thats the reasib we only use content + // TextComponent implements Serialize and writes in bytes instead of String, that's the reasib we only use content self.send_packet_now(&CLoginDisconnect::new( &serde_json::to_string(&reason.0).unwrap_or_else(|_| String::new()), )) diff --git a/pumpkin/src/net/proxy/velocity.rs b/pumpkin/src/net/proxy/velocity.rs index 07ca9e08f..40f9420ed 100644 --- a/pumpkin/src/net/proxy/velocity.rs +++ b/pumpkin/src/net/proxy/velocity.rs @@ -1,6 +1,6 @@ /// Proxy implementation for Velocity by `PaperMC` /// Sadly, `PaperMC` does not care about 3rd parties providing support for Velocity. There is no documentation. -/// I had to understand the code logic by looking at `PaperMC`'s Velocity implementation: +/// I had to understand the code logic by looking at `PaperMC`'s Velocity implementation: use std::{ io::Read, net::{IpAddr, SocketAddr}, diff --git a/pumpkin/src/server/mod.rs b/pumpkin/src/server/mod.rs index dc2062f21..0216da037 100644 --- a/pumpkin/src/server/mod.rs +++ b/pumpkin/src/server/mod.rs @@ -51,9 +51,9 @@ pub struct Server { /// Handles cryptographic keys for secure communication. key_store: KeyStore, /// Manages server status information. - server_listing: Mutex, + listing: Mutex, /// Saves server branding information. - server_branding: CachedBranding, + branding: CachedBranding, /// Saves and dispatches commands to appropriate handlers. pub command_dispatcher: RwLock, /// Block behaviour. @@ -74,6 +74,9 @@ pub struct Server { container_id: AtomicU32, /// Manages authentication with an authentication server, if enabled. pub auth_client: Option, + /// Mojang's public keys, used for chat session signing + /// Pulled from Mojang API on startup + pub mojang_public_keys: Mutex>, /// The server's custom bossbars pub bossbars: Mutex, /// The default gamemode when a player joins the server (reset every restart) @@ -81,9 +84,6 @@ pub struct Server { /// Manages player data storage pub player_data_storage: ServerPlayerData, tasks: TaskTracker, - /// Mojang's public keys, used for chat session signing - /// Pulled from Mojang API on startup - pub mojang_public_keys: Mutex>, } impl Server { @@ -133,8 +133,8 @@ impl Server { item_registry: super::item::items::default_registry(), auth_client, key_store: KeyStore::new(), - server_listing: Mutex::new(CachedStatus::new()), - server_branding: CachedBranding::new(), + listing: Mutex::new(CachedStatus::new()), + branding: CachedBranding::new(), bossbars: Mutex::new(CustomBossbars::new()), defaultgamemode: Mutex::new(DefaultGamemode { gamemode: BASIC_CONFIG.default_gamemode, @@ -225,7 +225,7 @@ impl Server { if let Some(config) = player.client.config.lock().await.as_ref() { // TODO: Config so we can also just ignore this hehe if config.server_listing { - self.server_listing.lock().await.add_player(); + self.listing.lock().await.add_player(); } } @@ -241,7 +241,7 @@ impl Server { pub async fn remove_player(&self) { // TODO: Config if we want decrease online - self.server_listing.lock().await.remove_player(); + self.listing.lock().await.remove_player(); } pub async fn shutdown(&self) { @@ -469,11 +469,11 @@ impl Server { } pub fn get_branding(&self) -> CPluginMessage<'_> { - self.server_branding.get_branding() + self.branding.get_branding() } pub fn get_status(&self) -> &Mutex { - &self.server_listing + &self.listing } pub fn encryption_request<'a>( diff --git a/pumpkin/src/server/seasonal_events.rs b/pumpkin/src/server/seasonal_events.rs index 1ce604d7a..2f6feed6b 100644 --- a/pumpkin/src/server/seasonal_events.rs +++ b/pumpkin/src/server/seasonal_events.rs @@ -2,7 +2,7 @@ use chrono::{Datelike, Local}; use pumpkin_config::advanced_config; use rand::{seq::SliceRandom, thread_rng}; -// Infact Mojang also has some Seasonal Events, so we can use that later to match Vanilla :D +// In fact Mojang also has some Seasonal Events, so we can use that later to match Vanilla :D #[must_use] pub fn is_april() -> bool { diff --git a/pumpkin/src/world/explosion.rs b/pumpkin/src/world/explosion.rs index 5242d5fd3..fbed8f03b 100644 --- a/pumpkin/src/world/explosion.rs +++ b/pumpkin/src/world/explosion.rs @@ -41,7 +41,8 @@ impl Explosion { let mut h = self.power * (0.7 + rand::random::() * 0.6); while h > 0.0 { let block_pos = BlockPos::floored(pos_x, pos_y, pos_z); - let block = world.get_block(&block_pos).await.unwrap(); + let (block, state) = + world.get_block_and_block_state(&block_pos).await.unwrap(); // if !world.is_in_build_limit(&block_pos) { // // Pass by reference @@ -49,8 +50,7 @@ impl Explosion { // } // TODO: This should only check air & fluid - // AIR has blast_resistance of 0 - if block.blast_resistance > 0.0 { + if !state.air { h -= (block.blast_resistance + 0.3) * 0.3; } if h > 0.0 { diff --git a/pumpkin/src/world/mod.rs b/pumpkin/src/world/mod.rs index 32e10dbd2..a164e942d 100644 --- a/pumpkin/src/world/mod.rs +++ b/pumpkin/src/world/mod.rs @@ -296,12 +296,12 @@ impl World { offset: Vector3, max_speed: f32, particle_count: i32, - pariticle: Particle, + particle: Particle, ) { let players = self.players.read().await; for (_, player) in players.iter() { player - .spawn_particle(position, offset, max_speed, particle_count, pariticle) + .spawn_particle(position, offset, max_speed, particle_count, particle) .await; } } @@ -1479,11 +1479,11 @@ impl World { pub async fn get_chunk(&self, position: &BlockPos) -> Arc> { let (chunk_coordinate, _) = position.chunk_and_chunk_relative_position(); - let chunk = match self.level.try_get_chunk(chunk_coordinate) { + + match self.level.try_get_chunk(chunk_coordinate) { Some(chunk) => chunk.clone(), None => self.receive_chunk(chunk_coordinate).await.0, - }; - chunk + } } pub async fn get_block_state_id(&self, position: &BlockPos) -> Result {