[PR #3563] [MERGED] Wither: stay still while charging, and spare itself from its spawn blast #5054

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

📋 Pull Request Information

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

Base: main ← Head: fix-3322


📝 Commits (1)

  • ab9ceb6 Wither: stay still while charging, and spare itself from its spawn blast

📊 Changes

5 files changed (+51 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/game/combat.rs (+4 -0)
📝 crates/horizon-client/src/game/creatures.rs (+2 -0)
📝 crates/horizon-client/src/game/explosion.rs (+7 -2)
📝 crates/horizon-client/src/mobs/wither.rs (+16 -3)
📝 tools/command_exec_corpus.py (+22 -0)

📄 Description

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

What and why

Fixes #3322

A wither that is still charging up (the blue, invulnerable phase after it is built) flew toward the mob it had targeted, and the blast that ends the charge hurt it (about 60 to 70 health in the tests below).

  • It moved while charging. WitherBoss.customServerAiStep returns early while getInvulnerableTicks() > 0, before it calls setAlternativeTarget(0, target). aiStep only flies toward the target that getAlternativeTarget(0) names, so a charging wither stays where it is. Horizon's custom_server_ai_step saved the target's position (extra.point, which steer flies toward) before the charge check. It now saves it after the charge check, as vanilla does. The target selector still runs during the charge, as in vanilla.
  • Its own blast hurt it. The blast is level.explode(this, ...) with the wither as its source, and ServerExplosion.hurtEntities collects entities with getEntities(source, box), which leaves the source out. Horizon guessed the source from a mob near the blast's centre and never left it out. The charging wither now sends MobEvent::ExplosionSource (as a creeper does), and the blast's mob loop skips a source that named itself this way, so the blast neither hurts it nor pushes it. A source that is only guessed is not skipped: a sulfur cube is already off the mob list when it blows up, so the guess there can be a bystander next to it, and that bystander is still hurt as before. Nothing else changes for other blasts: a creeper is already off the mob list when it explodes, and a projectile's blast has no source mob.

Vanilla reference

  • net.minecraft.world.entity.boss.wither.WitherBoss.customServerAiStep: the getInvulnerableTicks() > 0 branch returns before setAlternativeTarget(0, getTarget().getId()).
  • WitherBoss.aiStep: it only moves toward a target when getAlternativeTarget(0) > 0.
  • ServerLevel.explode(Entity source, ...) → ServerExplosion.hurtEntities: level.getEntities(this.source, box).

Read with javap -c -p on the 26.3 jars.

Harness: tools/command_exec_corpus.py gets a wither spawn group for test_command_exec_parity.py. It summons a wither with {Invul:20} on a stone floor, with a NoAI pig 10 blocks away. It reads the wither's Pos and Invul 10 ticks later, then its Invul and Health after the blast. I ran both sides by hand on Windows: the vanilla oracle VanillaCommandExecOracle against the 26.3 server jar, and horizon-client --in-frame with HORIZON_COMMAND_SCRIPT. I used the setup and wither spawn groups.

Before (main):

MISMATCH messages | /data get entity @e[type=minecraft:wither,limit=1] Pos
   rust    "Wither has the following entity data: [4.5d, 213.22044877771822d, 12.475347769941932d]"
   vanilla "Wither has the following entity data: [4.5d, 210.0d, 8.5d]"
ok | /data get entity @e[type=minecraft:wither,limit=1] Invul      (10)
ok | /data get entity @e[type=minecraft:wither,limit=1] Invul      (0)
MISMATCH messages | /data get entity @e[type=minecraft:wither,limit=1] Health
   rust    "Wither has the following entity data: 233.14197f"
   vanilla "Wither has the following entity data: 300.0f"
mismatches: 2/4

After (this branch):

ok | /data get entity @e[type=minecraft:wither,limit=1] Pos        [4.5d, 210.0d, 8.5d]
ok | /data get entity @e[type=minecraft:wither,limit=1] Invul      10
ok | /data get entity @e[type=minecraft:wither,limit=1] Invul      0
ok | /data get entity @e[type=minecraft:wither,limit=1] Health     300.0f
mismatches: 0/4

Self-check

Run on Windows 11. tools/pr_ready.py stops on Windows at signal.SIGHUP, so I ran the steps by hand:

cargo fmt --all -- --check                                                       ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings      ok
cargo test -p horizon-client --features mods --bin horizon-client explosion      3 passed
python tools/check_public_tree.py                                                passed
cargo test -p horizon-client --features mods --lib wither                       1 passed
command_exec harness, groups setup + wither spawn (by hand)                      4/4 match (2/4 before)
command_exec harness, groups setup + entities + wither spawn (by hand)           62/62 match

The "before" run is this branch with only the Rust change reverted, so the new group fails without the fix.

The mob_ai harness's wither_player scenario uses a summoned wither with no charge, so this change doesn't touch it. CI's parity job runs it.

In game

Default single player (server thread), creative. A wither is summoned with {Invul:220} 15 blocks in front of the player, and a NoAI pig 16 blocks behind it.

Before (v0.2.97): 4 s into the charge the wither has flown past the pig, up to y 125 and z 546. After the blast it has 237 health.

After (this branch): 4 s into the charge the wither is still where it was summoned ([202.5, 120.0, 528.5]). After the blast it has 300 health, and the crater is where it stood.

🤖 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/3563 **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-3322` --- ### 📝 Commits (1) - [`ab9ceb6`](https://github.com/horizon-rust/horizon/commit/ab9ceb6a6dda44c2acd9d8320ab18981f66698b6) Wither: stay still while charging, and spare itself from its spawn blast ### 📊 Changes **5 files changed** (+51 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/combat.rs` (+4 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+2 -0) 📝 `crates/horizon-client/src/game/explosion.rs` (+7 -2) 📝 `crates/horizon-client/src/mobs/wither.rs` (+16 -3) 📝 `tools/command_exec_corpus.py` (+22 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3322 A wither that is still charging up (the blue, invulnerable phase after it is built) flew toward the mob it had targeted, and the blast that ends the charge hurt it (about 60 to 70 health in the tests below). - **It moved while charging.** `WitherBoss.customServerAiStep` returns early while `getInvulnerableTicks() > 0`, before it calls `setAlternativeTarget(0, target)`. `aiStep` only flies toward the target that `getAlternativeTarget(0)` names, so a charging wither stays where it is. Horizon's `custom_server_ai_step` saved the target's position (`extra.point`, which `steer` flies toward) before the charge check. It now saves it after the charge check, as vanilla does. The target selector still runs during the charge, as in vanilla. - **Its own blast hurt it.** The blast is `level.explode(this, ...)` with the wither as its source, and `ServerExplosion.hurtEntities` collects entities with `getEntities(source, box)`, which leaves the source out. Horizon guessed the source from a mob near the blast's centre and never left it out. The charging wither now sends `MobEvent::ExplosionSource` (as a creeper does), and the blast's mob loop skips a source that named itself this way, so the blast neither hurts it nor pushes it. A source that is only guessed is not skipped: a sulfur cube is already off the mob list when it blows up, so the guess there can be a bystander next to it, and that bystander is still hurt as before. Nothing else changes for other blasts: a creeper is already off the mob list when it explodes, and a projectile's blast has no source mob. ## Vanilla reference - `net.minecraft.world.entity.boss.wither.WitherBoss.customServerAiStep`: the `getInvulnerableTicks() > 0` branch returns before `setAlternativeTarget(0, getTarget().getId())`. - `WitherBoss.aiStep`: it only moves toward a target when `getAlternativeTarget(0) > 0`. - `ServerLevel.explode(Entity source, ...)` → `ServerExplosion.hurtEntities`: `level.getEntities(this.source, box)`. Read with `javap -c -p` on the 26.3 jars. **Harness:** `tools/command_exec_corpus.py` gets a `wither spawn` group for `test_command_exec_parity.py`. It summons a wither with `{Invul:20}` on a stone floor, with a NoAI pig 10 blocks away. It reads the wither's `Pos` and `Invul` 10 ticks later, then its `Invul` and `Health` after the blast. I ran both sides by hand on Windows: the vanilla oracle `VanillaCommandExecOracle` against the 26.3 server jar, and `horizon-client --in-frame` with `HORIZON_COMMAND_SCRIPT`. I used the `setup` and `wither spawn` groups. Before (main): ``` MISMATCH messages | /data get entity @e[type=minecraft:wither,limit=1] Pos rust "Wither has the following entity data: [4.5d, 213.22044877771822d, 12.475347769941932d]" vanilla "Wither has the following entity data: [4.5d, 210.0d, 8.5d]" ok | /data get entity @e[type=minecraft:wither,limit=1] Invul (10) ok | /data get entity @e[type=minecraft:wither,limit=1] Invul (0) MISMATCH messages | /data get entity @e[type=minecraft:wither,limit=1] Health rust "Wither has the following entity data: 233.14197f" vanilla "Wither has the following entity data: 300.0f" mismatches: 2/4 ``` After (this branch): ``` ok | /data get entity @e[type=minecraft:wither,limit=1] Pos [4.5d, 210.0d, 8.5d] ok | /data get entity @e[type=minecraft:wither,limit=1] Invul 10 ok | /data get entity @e[type=minecraft:wither,limit=1] Invul 0 ok | /data get entity @e[type=minecraft:wither,limit=1] Health 300.0f mismatches: 0/4 ``` ## Self-check Run on Windows 11. `tools/pr_ready.py` stops on Windows at `signal.SIGHUP`, so I ran the steps by hand: ``` cargo fmt --all -- --check ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings ok cargo test -p horizon-client --features mods --bin horizon-client explosion 3 passed python tools/check_public_tree.py passed cargo test -p horizon-client --features mods --lib wither 1 passed command_exec harness, groups setup + wither spawn (by hand) 4/4 match (2/4 before) command_exec harness, groups setup + entities + wither spawn (by hand) 62/62 match ``` The "before" run is this branch with only the Rust change reverted, so the new group fails without the fix. The `mob_ai` harness's `wither_player` scenario uses a summoned wither with no charge, so this change doesn't touch it. CI's parity job runs it. ## In game Default single player (server thread), creative. A wither is summoned with `{Invul:220}` 15 blocks in front of the player, and a NoAI pig 16 blocks behind it. Before (v0.2.97): 4 s into the charge the wither has flown past the pig, up to y 125 and z 546. After the blast it has 237 health. After (this branch): 4 s into the charge the wither is still where it was summoned (`[202.5, 120.0, 528.5]`). After the blast it has 300 health, and the crater is where it stood. 🤖 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:54 +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#5054
No description provided.