[PR #7757] use_item_on: a lever and a button clicked with an empty hand #7801

Open
opened 2026-11-03 07:24:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7757
Author: @MSedgeMC
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: test/lever-button


📝 Commits (2)

  • 6ec822d use_item_on: add the lever and button click case
  • 95c2856 use_item_on: generate the lever and button case

📊 Changes

1 file changed (+33 additions, -0 deletions)

View changed files

📝 tools/test_use_item_on_parity.py (+33 -0)

📄 Description

Vanilla turns a lever or a button on BlockBehaviour.useWithoutItem, and nothing in the suite clicked one: test_redstone_parity.py fills a floor with levers, buttons, repeaters and comparators and then powers them through Level.setBlock, so the click path had no case.

LeverBlock.useWithoutItem answers SUCCESS on either state and calls pull: POWERED cycles, setBlockAndUpdate writes it, updateNeighbours notifies the lever's own block and the block it hangs on, block.lever.click plays at volume 0.3 with pitch 0.6 when the lever is now on and 0.5 when it is off, and GameEvent.BLOCK_ACTIVATE or BLOCK_DEACTIVATE follows (LeverBlock.pull, LeverBlock.playSound). ButtonBlock.useWithoutItem answers CONSUME and touches nothing while the button is already POWERED; otherwise ButtonBlock.press writes POWERED=true, updates the same neighbours, schedules the release ticksToStayPressed ticks out, plays the block set type's own button_on sound and sends BLOCK_ACTIVATE.

Horizon answers both on main (crates/horizon-world/src/level/interact.rs: Class::Lever -> lever_pull, Class::Button -> button_press, the ports of the same two vanilla methods in level/redstone.rs); this adds the case that pins them, which the suite lacked.

The case clicks a lever or any of the fourteen buttons with an empty hand: every face/facing a block can be attached by, POWERED either way (so the pressed button's CONSUME is exercised beside the unpressed one's press), a random click face, and a survival or creative player.

Proven:

  • python3 tools/test_use_item_on_parity.py, 4000 cases, with the new case: 4000/4000 cases match (0 oracle errors); vanilla planted in 710, started eating in 366, exploded 328 times and found a respawn spot in 371. 130 of those cases are lever or button clicks (13 levers, 117 buttons over the fourteen types).
  • With the Class::Lever and Class::Button arms of crates/horizon-world/src/level/interact.rs replaced by Consume, the same 4000 cases fail: 3929/4000 cases match, 71 differing, split empty hand on lever: 13 differing plus 58 button cases over the fourteen types (a button that is already POWERED answers CONSUME on both sides, so only the unpressed ones differ). Two of them, verbatim:
    • case 0,0,0=minecraft:lever[face=floor,facing=south,powered=true] ... use={"item": "-", "creative": true, ...} — native G 0,0,0 minecraft:block_deactivate | S 0,0,0 minecraft:block.lever.click | held - offhand - using - | respawn - | rng -1139579931322726268 | set 0,0,0 8442, Horizon only held - offhand - using - | respawn - | rng -1139579931322726268.
    • case 0,0,0=minecraft:warped_button[face=ceiling,facing=north,powered=false] ... — native G 0,0,0 minecraft:block_activate | S 0,0,0 minecraft:block.nether_wood_button.click_on | ... | set 0,0,0 24863, Horizon without the event, the sound and the state.

Not proven: nothing in a real client; the run is headless. The case does not tick the release a button scheduled, so the return to POWERED=false (ButtonBlock.checkPressed, its sound and BLOCK_DEACTIVATE) stays unpinned, and so does that same method's arrow-held button. Adventure mode is out of reach because the fixture clicks as a survival or creative player only, and both blocks ignore mayBuild in vanilla anyway.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/7757 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `test/lever-button` --- ### 📝 Commits (2) - [`6ec822d`](https://github.com/horizon-rust/horizon/commit/6ec822d5b9ac6cd2e9dabdab214cb2ec74698146) use_item_on: add the lever and button click case - [`95c2856`](https://github.com/horizon-rust/horizon/commit/95c28566db6542103eacbff8dee599477a4283f9) use_item_on: generate the lever and button case ### 📊 Changes **1 file changed** (+33 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `tools/test_use_item_on_parity.py` (+33 -0) </details> ### 📄 Description Vanilla turns a lever or a button on `BlockBehaviour.useWithoutItem`, and nothing in the suite clicked one: `test_redstone_parity.py` fills a floor with levers, buttons, repeaters and comparators and then powers them through `Level.setBlock`, so the click path had no case. `LeverBlock.useWithoutItem` answers `SUCCESS` on either state and calls `pull`: `POWERED` cycles, `setBlockAndUpdate` writes it, `updateNeighbours` notifies the lever's own block and the block it hangs on, `block.lever.click` plays at volume 0.3 with pitch 0.6 when the lever is now on and 0.5 when it is off, and `GameEvent.BLOCK_ACTIVATE` or `BLOCK_DEACTIVATE` follows (`LeverBlock.pull`, `LeverBlock.playSound`). `ButtonBlock.useWithoutItem` answers `CONSUME` and touches nothing while the button is already `POWERED`; otherwise `ButtonBlock.press` writes `POWERED=true`, updates the same neighbours, schedules the release `ticksToStayPressed` ticks out, plays the block set type's own `button_on` sound and sends `BLOCK_ACTIVATE`. Horizon answers both on `main` (`crates/horizon-world/src/level/interact.rs`: `Class::Lever` -> `lever_pull`, `Class::Button` -> `button_press`, the ports of the same two vanilla methods in `level/redstone.rs`); this adds the case that pins them, which the suite lacked. The case clicks a lever or any of the fourteen buttons with an empty hand: every `face`/`facing` a block can be attached by, `POWERED` either way (so the pressed button's `CONSUME` is exercised beside the unpressed one's press), a random click face, and a survival or creative player. **Proven:** - `python3 tools/test_use_item_on_parity.py`, 4000 cases, with the new case: `4000/4000 cases match (0 oracle errors); vanilla planted in 710, started eating in 366, exploded 328 times and found a respawn spot in 371`. 130 of those cases are lever or button clicks (13 levers, 117 buttons over the fourteen types). - With the `Class::Lever` and `Class::Button` arms of `crates/horizon-world/src/level/interact.rs` replaced by `Consume`, the same 4000 cases fail: `3929/4000 cases match`, 71 differing, split `empty hand on lever: 13 differing` plus 58 button cases over the fourteen types (a button that is already `POWERED` answers `CONSUME` on both sides, so only the unpressed ones differ). Two of them, verbatim: - `case 0,0,0=minecraft:lever[face=floor,facing=south,powered=true] ... use={"item": "-", "creative": true, ...}` — native `G 0,0,0 minecraft:block_deactivate | S 0,0,0 minecraft:block.lever.click | held - offhand - using - | respawn - | rng -1139579931322726268 | set 0,0,0 8442`, Horizon only `held - offhand - using - | respawn - | rng -1139579931322726268`. - `case 0,0,0=minecraft:warped_button[face=ceiling,facing=north,powered=false] ...` — native `G 0,0,0 minecraft:block_activate | S 0,0,0 minecraft:block.nether_wood_button.click_on | ... | set 0,0,0 24863`, Horizon without the event, the sound and the state. **Not proven:** nothing in a real client; the run is headless. The case does not tick the release a button scheduled, so the return to `POWERED=false` (`ButtonBlock.checkPressed`, its sound and `BLOCK_DEACTIVATE`) stays unpinned, and so does that same method's arrow-held button. Adventure mode is out of reach because the fixture clicks as a survival or creative player only, and both blocks ignore `mayBuild` in vanilla anyway. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7801
No description provided.