Merge pull request #702 from ludovic111/perf/hopper-tick-prefilter

Hoppers: look up the block only under container block entities
This commit is contained in:
Ludovic Marie
2026-10-17 16:31:02 +02:00
committed by GitHub
+6 -2
View File
@@ -506,11 +506,15 @@ impl Game<'_> {
.default_state("minecraft:hopper")
.map(|s| self.res.facts.get(s).name.clone());
let Some(hopper) = hopper else { return Ok(()) };
// A hopper's block entity is a plain container (`Chest`): only those
// need their block looked up (the ticker runs for a HopperBlockEntity
// whose block is still a hopper, `BlockEntityType.isValid`).
let mut positions: Vec<Pos> = self
.world
.block_entities
.keys()
.copied()
.iter()
.filter(|(_, e)| matches!(e, BlockEntity::Chest(_)))
.map(|(p, _)| *p)
.filter(|p| self.res.facts.get(self.world.block(p.0, p.1, p.2)).name == hopper)
.collect();
positions.sort_unstable();