diff --git a/crates/horizon-client/src/game/block_entity_ticks.rs b/crates/horizon-client/src/game/block_entity_ticks.rs index 2778bb531..edb29a305 100644 --- a/crates/horizon-client/src/game/block_entity_ticks.rs +++ b/crates/horizon-client/src/game/block_entity_ticks.rs @@ -23,7 +23,11 @@ impl Game<'_> { let states = self.ticking_states(); self.world.block_entities.set_states(states); } - self.forget_gone_hoppers(); + // Only lingering cooldowns are dropped; a hopper that ticks checks + // its own block. Once a second is soon enough for the rest. + if self.world.game_time % 20 == 0 { + self.forget_gone_hoppers(); + } let ticking = self.block_ticking_area(); let mut spawners = Vec::new(); let mut trial_spawners = Vec::new(); diff --git a/crates/horizon-client/src/game/machines.rs b/crates/horizon-client/src/game/machines.rs index f9a208a7f..4a6fca181 100644 --- a/crates/horizon-client/src/game/machines.rs +++ b/crates/horizon-client/src/game/machines.rs @@ -595,6 +595,18 @@ impl Game<'_> { /// `HopperBlockEntity.pushItemsTick` of the hopper at `pos`, if its block /// is still a hopper (`BlockEntityType.isValid`). pub(super) fn tick_hopper(&mut self, pos: Pos) { + let time = self.world.game_time; + let waiting = { + let state = self.hoppers.entry(pos).or_default(); + state.cooldown -= 1; + state.ticked = time; + state.cooldown > 0 + }; + if waiting { + return; + } + // Most ticks only advance the cooldown: the block is checked when the + // hopper is about to move, not on every tick it waits. let hopper = self .res .facts() @@ -606,14 +618,10 @@ impl Game<'_> { self.hoppers.remove(&pos); return; } - let time = self.world.game_time; - let state = self.hoppers.entry(pos).or_default(); - state.cooldown -= 1; - state.ticked = time; - if state.cooldown <= 0 { + if let Some(state) = self.hoppers.get_mut(&pos) { state.cooldown = 0; - self.hopper_try_move_items(pos); } + self.hopper_try_move_items(pos); } /// Drops the cooldowns of hoppers whose block entity is gone. pub(super) fn forget_gone_hoppers(&mut self) {