[PR #3575] [MERGED] Wither: broken blocks give way to their fluid, so water stays water #5065

Closed
opened 2026-11-03 05:09:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3575
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix-3153


📝 Commits (4)

  • 11d3f08 Wither: broken blocks give way to their fluid, so water stays water
  • 3e1f398 Merge main into fix-3153: keep both the wither breaks and ender dragon corpus groups
  • 9afb898 Merge remote-tracking branch 'origin/main' into fix-3153
  • f5de793 Wither breaks parity: hold the wither in place until it breaks

📊 Changes

4 files changed (+43 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+7 -1)
📝 crates/horizon-client/src/mobs.rs (+2 -1)
📝 crates/horizon-client/src/mobs/wither.rs (+4 -1)
📝 tools/command_exec_corpus.py (+30 -0)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

Fixes #3153

When a wither is hurt, it breaks the blocks around it 20 ticks later. In Horizon it also removed water: a wither in a pool left a 3×3×4 air pocket around itself, and waterlogged blocks lost their water.

The cause was the mob BreakBlock event handler (game/creatures.rs). It wrote air into the cell with a raw world.set, so:

  • a water or lava cell turned into air,
  • a waterlogged block turned into air,
  • neighbours were not updated, so the pool around the hole never flowed back in.

Vanilla's Level.destroyBlock instead sets the cell to fluidState.createLegacyBlock() with flag 3. The handler now does the same: it sets the old state's fluid block (air when there is no fluid) through level_set, which goes through the behaviour library's setBlock with UPDATE_ALL. When the cell already holds that block (a liquid), it skips the write, matching vanilla's setBlock, which returns false for an unchanged state.

destroyBlock returns that setBlock result, and WitherBoss plays its break sound (level event 1022) only if at least one call returned true. The wither now counts only cells that are not already liquid, so a wither surrounded only by water stays silent, as in vanilla.

Other mobs that use BreakBlock (ravager, silverfish, sheep eating grass, villager farming, zombies on turtle eggs) also call destroyBlock/removeBlock in vanilla, so they get the same fluid-keeping behaviour and neighbour updates.

Vanilla reference

  • net.minecraft.world.level.Level.destroyBlock(BlockPos, boolean, Entity, int): spawnDestroyParticles, dropResources, then setBlock(pos, getFluidState(pos).createLegacyBlock(), 3, limit), returning that result.
  • net.minecraft.world.entity.boss.wither.WitherBoss.customServerAiStep: destroyBlocksTick countdown, canDestroy(state) (not air, not #wither_immune), destroyed = level.destroyBlock(pos, true, this) || destroyed, then level event 1022.
  • Water block properties in Blocks: noLootTable, liquid, SoundType.EMPTY.

Harness: tools/test_command_exec_parity.py gets a new wither breaks group (tools/command_exec_corpus.py). It builds a water pool with stone, a waterlogged oak stair and an oak slab inside, summons a NoGravity wither there, hurts it with /damage, holds it in place with /tp each tick until it breaks (its random stroll would otherwise move the box), waits 40 ticks in all, and then probes the cells with /execute if block. The real 26.3 server is the oracle.

Self-check

tools/pr_ready.py and tools/parity.py do not run on Windows (signal.SIGHUP is missing), so I ran these commands instead:

cargo fmt --all -- --check                                              # OK
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings   # OK (before the merge of main)
python tools/check_public_tree.py                                       # Public tree check passed.
python tools/test_command_exec_parity.py --only wither                  # see below

After review, on macOS (f5de793b3, main merged in): python3 tools/parity.py command_exec --fresh passes, wither breaks: 9/9, total: 902/902, three runs in a row. cargo clippy -p horizon-client --all-targets --no-deps -- -D warnings is clean; the mods feature is gone from main.

Without the fix (the Rust changes reverted, the harness group kept):

wither breaks: 5/9 commands match
messages '/execute if block 8 212 8 minecraft:water'
  vanilla {"messages": ["Test passed"], ...}
  rust    {"messages": ["Test failed"], ...}
messages '/execute if block 9 211 9 minecraft:water'
  vanilla {"messages": ["Test passed"], ...}
  rust    {"messages": ["Test failed"], ...}
messages '/execute if block 7 210 7 minecraft:water'
  vanilla {"messages": ["Test passed"], ...}
  rust    {"messages": ["Test failed"], ...}
messages '/execute if block 7 212 9 minecraft:water'
  vanilla {"messages": ["Test passed"], ...}
  rust    {"messages": ["Test failed"], ...}
total: 5/9 commands match
4 command execution mismatches

With the fix:

wither breaks: 9/9 commands match
total: 9/9 commands match

In game

In game (server thread, creative): a 9×10×9 water cube held up by barriers, with a wither summoned inside and hurt once with /damage. Four seconds later:

  • Before: the wither carved a 3×3×4 air pocket out of the water. /execute if block on the water cell, the waterlogged stair and the broken stone all reported Test failed.
  • After: the stone, slab and stair are gone and the water is intact. The same three probes reported Test passed.

🤖 Generated with Claude Code


🔄 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/3575 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix-3153` --- ### 📝 Commits (4) - [`11d3f08`](https://github.com/horizon-rust/horizon/commit/11d3f08c1202e275af5467f64d62637102be6b4f) Wither: broken blocks give way to their fluid, so water stays water - [`3e1f398`](https://github.com/horizon-rust/horizon/commit/3e1f39899cbff5844ca166b7c675d5c87959d626) Merge main into fix-3153: keep both the wither breaks and ender dragon corpus groups - [`9afb898`](https://github.com/horizon-rust/horizon/commit/9afb898e80d388d95abc9bc018bc267601fc3093) Merge remote-tracking branch 'origin/main' into fix-3153 - [`f5de793`](https://github.com/horizon-rust/horizon/commit/f5de793b38c408a7805a8c117b0ca84470d08d82) Wither breaks parity: hold the wither in place until it breaks ### 📊 Changes **4 files changed** (+43 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+7 -1) 📝 `crates/horizon-client/src/mobs.rs` (+2 -1) 📝 `crates/horizon-client/src/mobs/wither.rs` (+4 -1) 📝 `tools/command_exec_corpus.py` (+30 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3153 When a wither is hurt, it breaks the blocks around it 20 ticks later. In Horizon it also removed water: a wither in a pool left a 3×3×4 air pocket around itself, and waterlogged blocks lost their water. The cause was the mob `BreakBlock` event handler (`game/creatures.rs`). It wrote air into the cell with a raw `world.set`, so: - a water or lava cell turned into air, - a waterlogged block turned into air, - neighbours were not updated, so the pool around the hole never flowed back in. Vanilla's `Level.destroyBlock` instead sets the cell to `fluidState.createLegacyBlock()` with flag 3. The handler now does the same: it sets the old state's fluid block (air when there is no fluid) through `level_set`, which goes through the behaviour library's `setBlock` with `UPDATE_ALL`. When the cell already holds that block (a liquid), it skips the write, matching vanilla's `setBlock`, which returns false for an unchanged state. `destroyBlock` returns that `setBlock` result, and `WitherBoss` plays its break sound (level event 1022) only if at least one call returned true. The wither now counts only cells that are not already liquid, so a wither surrounded only by water stays silent, as in vanilla. Other mobs that use `BreakBlock` (ravager, silverfish, sheep eating grass, villager farming, zombies on turtle eggs) also call `destroyBlock`/`removeBlock` in vanilla, so they get the same fluid-keeping behaviour and neighbour updates. ## Vanilla reference - `net.minecraft.world.level.Level.destroyBlock(BlockPos, boolean, Entity, int)`: `spawnDestroyParticles`, `dropResources`, then `setBlock(pos, getFluidState(pos).createLegacyBlock(), 3, limit)`, returning that result. - `net.minecraft.world.entity.boss.wither.WitherBoss.customServerAiStep`: `destroyBlocksTick` countdown, `canDestroy(state)` (not air, not `#wither_immune`), `destroyed = level.destroyBlock(pos, true, this) || destroyed`, then level event 1022. - Water block properties in `Blocks`: `noLootTable`, `liquid`, `SoundType.EMPTY`. Harness: `tools/test_command_exec_parity.py` gets a new `wither breaks` group (`tools/command_exec_corpus.py`). It builds a water pool with stone, a waterlogged oak stair and an oak slab inside, summons a `NoGravity` wither there, hurts it with `/damage`, holds it in place with `/tp` each tick until it breaks (its random stroll would otherwise move the box), waits 40 ticks in all, and then probes the cells with `/execute if block`. The real 26.3 server is the oracle. ## Self-check `tools/pr_ready.py` and `tools/parity.py` do not run on Windows (`signal.SIGHUP` is missing), so I ran these commands instead: ``` cargo fmt --all -- --check # OK cargo clippy -p horizon-client --features mods --all-targets -- -D warnings # OK (before the merge of main) python tools/check_public_tree.py # Public tree check passed. python tools/test_command_exec_parity.py --only wither # see below ``` After review, on macOS (`f5de793b3`, main merged in): `python3 tools/parity.py command_exec --fresh` passes, `wither breaks: 9/9`, `total: 902/902`, three runs in a row. `cargo clippy -p horizon-client --all-targets --no-deps -- -D warnings` is clean; the `mods` feature is gone from main. Without the fix (the Rust changes reverted, the harness group kept): ``` wither breaks: 5/9 commands match messages '/execute if block 8 212 8 minecraft:water' vanilla {"messages": ["Test passed"], ...} rust {"messages": ["Test failed"], ...} messages '/execute if block 9 211 9 minecraft:water' vanilla {"messages": ["Test passed"], ...} rust {"messages": ["Test failed"], ...} messages '/execute if block 7 210 7 minecraft:water' vanilla {"messages": ["Test passed"], ...} rust {"messages": ["Test failed"], ...} messages '/execute if block 7 212 9 minecraft:water' vanilla {"messages": ["Test passed"], ...} rust {"messages": ["Test failed"], ...} total: 5/9 commands match 4 command execution mismatches ``` With the fix: ``` wither breaks: 9/9 commands match total: 9/9 commands match ``` ## In game In game (server thread, creative): a 9×10×9 water cube held up by barriers, with a wither summoned inside and hurt once with `/damage`. Four seconds later: - **Before:** the wither carved a 3×3×4 air pocket out of the water. `/execute if block` on the water cell, the waterlogged stair and the broken stone all reported `Test failed`. - **After:** the stone, slab and stair are gone and the water is intact. The same three probes reported `Test passed`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:09:59 +07:00
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#5065
No description provided.