From 3d4edce3b5ebc2b000e424f070b2490ab8a5c417 Mon Sep 17 00:00:00 2001 From: Cayden Tisdale <73692034+Phoenixxo@users.noreply.github.com> Date: Sat, 29 Aug 2026 06:36:38 +0000 Subject: [PATCH] fix(world): correctly use random tick speed gamerule value (#2904) Signed-off-by: Cayden Tisdale <73692034+Phoenixxo@users.noreply.github.com> --- crates/pumpkin-world/src/level.rs | 10 ++++++++-- crates/pumpkin/src/world/mod.rs | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/pumpkin-world/src/level.rs b/crates/pumpkin-world/src/level.rs index b4c820285..29bfb1328 100644 --- a/crates/pumpkin-world/src/level.rs +++ b/crates/pumpkin-world/src/level.rs @@ -498,7 +498,13 @@ impl Level { }); } - pub fn get_tick_data(&self, active_chunks: &FxHashSet>) -> TickData { + pub fn get_tick_data( + &self, + active_chunks: &FxHashSet>, + random_tick_speed: i64, + ) -> TickData { + let samples_per_section = random_tick_speed.max(0); + let mut ticks = TickData { block_ticks: Vec::new(), fluid_ticks: Vec::new(), @@ -528,7 +534,7 @@ impl Level { continue; } let y_base = min_y + (i as i32 * 16); - for _ in 0..3 { + for _ in 0..samples_per_section { let r = rand::random::(); let x_offset = (r & 0xF) as usize; let z_offset = (r >> 8 & 0xF) as usize; diff --git a/crates/pumpkin/src/world/mod.rs b/crates/pumpkin/src/world/mod.rs index 366897428..9fd3660b8 100644 --- a/crates/pumpkin/src/world/mod.rs +++ b/crates/pumpkin/src/world/mod.rs @@ -1640,9 +1640,10 @@ impl World { #[expect(clippy::too_many_lines)] pub fn tick_chunks(self: &Arc, server: &Arc) { const BATCH_SIZE: usize = 32; + let random_tick_speed = self.level_info.load().game_rules.random_tick_speed; let active_chunks = self.active_chunks.load(); - let tick_data = self.level.get_tick_data(&active_chunks); + let tick_data = self.level.get_tick_data(&active_chunks, random_tick_speed); let handle = server.runtime.clone(); // 1. Parallel Block Ticks via Rayon