From df90f62d354b38b62c452a7d266c000213d62199 Mon Sep 17 00:00:00 2001 From: Hector Eccles Date: Tue, 27 Oct 2026 21:28:52 -0400 Subject: [PATCH] Hopper ticks check their block only when they move A hopper on its 8-tick cooldown looked up its block and compared the state name every tick, then returned without moving. Advance the cooldown first and only resolve the block when it is due to move. The sweep that drops hoppers whose block entity is gone can run once a second; a hopper that ticks still checks its own block. Co-Authored-By: OpenCode --- .../src/game/block_entity_ticks.rs | 6 +++++- crates/horizon-client/src/game/machines.rs | 20 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) 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) {