Merge pull request #2004 from ludovic111/perf/sculk-ticking-chunks

🤖 Agent: pr_ready and 91 harnesses pass (shared run, body); tick_sculk_blocks halved at 10 bots, −75% at 25. Queued by perf-next-2.
This commit is contained in:
Ludovic Marie
2026-10-26 03:38:40 +01:00
committed by GitHub
2 changed files with 19 additions and 5 deletions
+12 -5
View File
@@ -718,17 +718,24 @@ impl Game<'_> {
})
};
// The ticking ones in the index's order, with whether the chunks
// around them tick too.
// around them tick too. Most sensors and catalysts wait for a
// vibration or a death: their tick would change nothing, so they
// are passed over here (a vibration scheduled during these ticks is
// chosen on the next tick at the earliest, as in vanilla).
let entities = &self.world.block_entities;
let due: Vec<((i32, i32, i32), bool)> = self
.sculk
.index
.iter()
.filter_map(|&key| {
let (cx, cz) = (key.0 >> 4, key.2 >> 4);
ticks(cx, cz).then(|| {
let adjacent = (-1..=1).all(|dx| (-1..=1).all(|dz| ticks(cx + dx, cz + dz)));
(key, adjacent)
})
if !ticks(cx, cz)
|| matches!(entities.get(&key), Some(BlockEntity::Sculk(e)) if e.idle())
{
return None;
}
let adjacent = (-1..=1).all(|dx| (-1..=1).all(|dz| ticks(cx + dx, cz + dz)));
Some((key, adjacent))
})
.collect();
for (key, adjacent) in due {
+7
View File
@@ -413,6 +413,13 @@ impl SculkEntity {
spreader: SculkSpreader::default(),
}
}
/// Whether its block entity tick does nothing: no vibration chosen
/// or on its way, none waiting to be chosen, and no charge to spread.
pub fn idle(&self) -> bool {
self.vibration.current.is_none()
&& self.vibration.selector.current().is_none()
&& self.spreader.cursors.is_empty()
}
pub fn for_block(name: &str) -> Option<Self> {
Some(Self::new(match name {
"minecraft:sculk_sensor" => SculkKind::Sensor,