Smaller fixes

This commit is contained in:
Alexander Medvedev committed 2025-07-31 10:29:41 +02:00
1 parent fab33370b5
commit 7468f2cf76
4 files changed
+4 -34

No files matched your search

+1 -5
View File
@@ -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
}
-25
View File
@@ -55,9 +55,6 @@ pub struct Level {
block_registry: Arc<dyn BlockRegistryExt>,
level_folder: LevelFolder,
// Holds this level's spawn chunks, which are always loaded
spawn_chunks: Arc<DashMap<Vector2<i32>, 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<Self>, chunks: &[Vector2<i32>]) {
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
+2 -2
View File
@@ -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
}
}
+1 -2
View File
@@ -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);
}
}}
}