From 7468f2cf763c81e78dd08661089858135099753c Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Thu, 31 Jul 2025 10:29:41 +0200 Subject: [PATCH] Smaller fixes --- pumpkin-util/src/math/mod.rs | 6 +----- pumpkin-world/src/level.rs | 25 ------------------------- pumpkin/src/entity/ai/control/mod.rs | 4 ++-- pumpkin/src/net/java/play.rs | 3 +-- 4 files changed, 4 insertions(+), 34 deletions(-) diff --git a/pumpkin-util/src/math/mod.rs b/pumpkin-util/src/math/mod.rs index 13407190b..9cc41fc0f 100644 --- a/pumpkin-util/src/math/mod.rs +++ b/pumpkin-util/src/math/mod.rs @@ -23,13 +23,9 @@ pub fn wrap_degrees(degrees: f32) -> f32 { var1 } -pub fn clamp(value: f32, min: f32, max: f32) -> f32 { - if value < min { min } else { value.min(max) } -} - pub fn clamp_angle(value: f32, mean: f32, delta: f32) -> f32 { let i = subtract_angles(value, mean); - let j = clamp(i, -delta, delta); + let j = i.clamp(-delta, delta); mean - j } diff --git a/pumpkin-world/src/level.rs b/pumpkin-world/src/level.rs index 8156423f7..5b144bd8f 100644 --- a/pumpkin-world/src/level.rs +++ b/pumpkin-world/src/level.rs @@ -55,9 +55,6 @@ pub struct Level { block_registry: Arc, level_folder: LevelFolder, - // Holds this level's spawn chunks, which are always loaded - spawn_chunks: Arc, SyncChunk>>, - /// Counts the number of ticks that have been scheduled for this world schedule_tick_counts: AtomicU64, @@ -151,7 +148,6 @@ impl Level { chunk_saver, entity_saver, schedule_tick_counts: AtomicU64::new(0), - spawn_chunks: Arc::new(DashMap::new()), loaded_chunks: Arc::new(DashMap::new()), loaded_entity_chunks: Arc::new(DashMap::new()), chunk_watchers: Arc::new(DashMap::new()), @@ -667,22 +663,6 @@ impl Level { } } - /// Initializes the spawn chunks to these chunks - pub async fn read_spawn_chunks(self: &Arc, chunks: &[Vector2]) { - let (send, mut recv) = mpsc::unbounded_channel(); - - let fetcher = self.fetch_chunks(chunks, send); - let handler = async { - while let Some((chunk, _)) = recv.recv().await { - let pos = chunk.read().await.position; - self.spawn_chunks.insert(pos, chunk); - } - }; - - let _ = tokio::join!(fetcher, handler); - log::debug!("Read {} chunks as spawn chunks", chunks.len()); - } - /// Reads/Generates many chunks in a world /// Note: The order of the output chunks will almost never be in the same order as the order of input chunks pub async fn fetch_chunks( @@ -708,11 +688,6 @@ impl Level { for chunk in chunks { let is_ok = if let Some(chunk) = self.loaded_chunks.get(chunk) { send_chunk(false, chunk.value().clone(), &channel) - } else if let Some(spawn_chunk) = self.spawn_chunks.get(chunk) { - // Also clone the arc into the loaded chunks - self.loaded_chunks - .insert(*chunk, spawn_chunk.value().clone()); - send_chunk(false, spawn_chunk.value().clone(), &channel) } else { remaining_chunks.push(*chunk); true diff --git a/pumpkin/src/entity/ai/control/mod.rs b/pumpkin/src/entity/ai/control/mod.rs index c422454e1..695885991 100644 --- a/pumpkin/src/entity/ai/control/mod.rs +++ b/pumpkin/src/entity/ai/control/mod.rs @@ -1,11 +1,11 @@ -use pumpkin_util::math::{clamp, subtract_angles}; +use pumpkin_util::math::subtract_angles; pub mod look_control; pub trait Control: Send + Sync { fn change_angle(&self, start: f32, end: f32, max_change: f32) -> f32 { let i = subtract_angles(start, end); - let j = clamp(i, -max_change, max_change); + let j = i.clamp(-max_change, max_change); start + j } } diff --git a/pumpkin/src/net/java/play.rs b/pumpkin/src/net/java/play.rs index 46aa50671..e9c57be90 100644 --- a/pumpkin/src/net/java/play.rs +++ b/pumpkin/src/net/java/play.rs @@ -1446,7 +1446,6 @@ impl JavaClient { server, ) .await; - self.update_sequence(player, use_item_on.sequence.0); // Check if the item is a block, because not every item can be placed :D if let Some(block) = Block::from_item_id(item.lock().await.item.id) { @@ -1556,6 +1555,7 @@ impl JavaClient { self.kick(TextComponent::text("InvalidHand")).await; return; }; + self.update_sequence(player, use_item.sequence.0); let item_in_hand = if hand == Hand::Left { inventory.held_item() } else { @@ -1603,7 +1603,6 @@ impl JavaClient { let item = held.item; drop(held); server.item_registry.on_use(item, player).await; - self.update_sequence(player, use_item.sequence.0); } }} }