From 2876752a3693fc0299b55fe7577b3528fedfbeee Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sat, 10 Oct 2026 19:32:30 +0200 Subject: [PATCH] Read an empty lectern's comparator signal in the block fixture The oracle now gives comparators and lecterns real block entities, so a lectern whose state has a book reads page progress 1 of an empty book and signals 14. The fixture's stand-in block entities now do the same, and the redstone harness matches on 8,000 of 8,000 cases with a second seed. Co-Authored-By: Claude Opus 5.5 --- .../examples/block_update_fixture.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/horizon-world/examples/block_update_fixture.rs b/crates/horizon-world/examples/block_update_fixture.rs index 816af34f5..0e5e28f91 100644 --- a/crates/horizon-world/examples/block_update_fixture.rs +++ b/crates/horizon-world/examples/block_update_fixture.rs @@ -33,6 +33,7 @@ struct Cells { thundering: bool, events: Vec, command_blocks: HashMap, + lecterns_with_books: std::rc::Rc>, } impl LevelAccess for Cells { fn block_state(&self, pos: BlockPos) -> BlockStateId { @@ -50,6 +51,11 @@ impl LevelAccess for Cells { fn is_loaded(&self, _pos: BlockPos) -> bool { true } + /// Fresh block entities hold nothing, but a lectern whose state has a book + /// reads page progress 1 of an empty book: signal 14. + fn block_entity_analog_signal(&self, _pos: BlockPos, state: BlockStateId, _direction: Direction) -> i32 { + if self.lecterns_with_books.contains(&state) { 14 } else { 0 } + } /// A chest's fresh block entity: nobody has it open. fn recheck_container_openers(&mut self, _pos: BlockPos) -> Option<(i32, i32)> { Some((0, 0)) @@ -131,6 +137,16 @@ fn main() -> Result<(), Box> { let registry = load_registry(resources)?; let behaviours = Behaviours::load(®istry, resources)?; let air = registry.default_state("minecraft:air").unwrap(); + let lecterns_with_books: std::rc::Rc> = std::rc::Rc::new( + (0..registry.len() as u32) + .map(BlockStateId) + .filter(|&id| { + registry.state(id).is_some_and(|s| { + s.name == "minecraft:lectern" && s.properties.get("has_book").is_some_and(|v| v == "true") + }) + }) + .collect(), + ); let mut out = std::io::BufWriter::new(std::fs::File::create(output)?); for (index, line) in std::io::BufReader::new(std::fs::File::open(cases)?) .lines() @@ -171,6 +187,7 @@ fn main() -> Result<(), Box> { .unwrap_or(false), events: Vec::new(), command_blocks: HashMap::new(), + lecterns_with_books: lecterns_with_books.clone(), }; let mut ticks = Ticks::new(0); for x in -3..=3 {