[PR #6137] [MERGED] A sulfur cube with a block takes a blow's extra knockback through its own launch #6673

Closed
opened 2026-11-03 06:24:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6137
Author: @xFedeT
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/sulfur-extra-knockback


📝 Commits (3)

  • f27a64e A sulfur cube with a block takes a blow's extra knockback through SulfurCube.knockback
  • 4aaba70 Merge main into #6137 (the mod block entity test fix, #6143)
  • 3c2fca6 Merge main into #6137 (#6146's resistance test passes launch's new scale)

📊 Changes

3 files changed (+90 additions, -24 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -1)
📝 crates/horizon-client/src/mobs.rs (+20 -1)
📝 crates/horizon-client/src/mobs/sulfur_cube.rs (+69 -22)

📄 Description

🤖 Opened by xFedeT's AI agent (Claude Code, Sonnet 5.5), not by xFedeT personally.

Fixes #6112 (the player's melee path, which the issue measured; the sweep, spear and goat paths are listed below).

What was wrong

SulfurCube.hurtServer knocks a cube with a block with dealDefaultKnockback and returns true for the blows in #sulfur_cube_with_block_immune_to. Player.attack then runs causeExtraKnockback (sprint, the Knockback enchantment) and the rest of its aftermath, and that push reaches the cube's own SulfurCube.knockback with comesFromEffect: the launch is scaled by sqrt(damage) * power * 0.25. Horizon's accepts_damage returned false, so attack_mob took the hit as not landed and skipped everything after it, and a sprint or Knockback push (when it did run) went through the generic Mob::knockback.

What changes

  • Mob::damage_with answers sulfur_cube::immune_to(source) (true) for a cube with a block that only took a knock; the tag is a named function now (immune_to).
  • launch takes the effect scale (1.0 for the blow's own push, power * 0.25 for an extra one); sulfur_cube::knockback takes the effect power.
  • Mob::knockback_effect(power, xd, zd, source, damage): a cube with a block and a causing entity goes through its own knockback, anything else through Mob::knockback as before. attack_mob uses it for the player's sprint and Knockback push.

Verification

  • an_effect_push_is_a_fraction_of_the_blows_own: a sprint push (power 0.5) is 0.125 of the blow's own on every axis, a Knockback II push 0.25, the factors the issue's table shows (0.66 → 0.7425 → 0.825 is x1, x1.125, x1.25).
  • The existing immune-tag test now expects the true answer vanilla gives (health is still unchanged); 275 horizon-client mobs:: tests pass, clippy and rustfmt are clean for the changed files except the existing needless_borrow in horizon-world. I did not run tools/test_server_knockback_parity.py (needs the vanilla jar and a newer Python); the issue's numbers are the cases to compare, and CI runs it.

Not done

  • The sweep neighbours (game/mace.rs), the spear (game/spear.rs) and MobEvent::Knockback (a goat's ram, a mob's spear) still call Mob::knockback, so they do not reach the cube's override. Only the player's melee push is routed here.
  • #6113 (the cube's knockback resistance is -1 in vanilla) is a separate cause and not touched.

🤖 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/6137 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/sulfur-extra-knockback` --- ### 📝 Commits (3) - [`f27a64e`](https://github.com/horizon-rust/horizon/commit/f27a64e87318ddaffbe8b012c391d37236558907) A sulfur cube with a block takes a blow's extra knockback through SulfurCube.knockback - [`4aaba70`](https://github.com/horizon-rust/horizon/commit/4aaba7056d32471351a05a34cb737289decd92cf) Merge main into #6137 (the mod block entity test fix, #6143) - [`3c2fca6`](https://github.com/horizon-rust/horizon/commit/3c2fca6a602c620b80235a2e6085b86c43dfb608) Merge main into #6137 (#6146's resistance test passes launch's new scale) ### 📊 Changes **3 files changed** (+90 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -1) 📝 `crates/horizon-client/src/mobs.rs` (+20 -1) 📝 `crates/horizon-client/src/mobs/sulfur_cube.rs` (+69 -22) </details> ### 📄 Description > 🤖 Opened by xFedeT's AI agent (Claude Code, Sonnet 5.5), not by xFedeT personally. Fixes #6112 (the player's melee path, which the issue measured; the sweep, spear and goat paths are listed below). ## What was wrong `SulfurCube.hurtServer` knocks a cube with a block with `dealDefaultKnockback` and **returns true** for the blows in `#sulfur_cube_with_block_immune_to`. `Player.attack` then runs `causeExtraKnockback` (sprint, the Knockback enchantment) and the rest of its aftermath, and that push reaches the cube's own `SulfurCube.knockback` with `comesFromEffect`: the launch is scaled by `sqrt(damage) * power * 0.25`. Horizon's `accepts_damage` returned **false**, so `attack_mob` took the hit as not landed and skipped everything after it, and a sprint or Knockback push (when it did run) went through the generic `Mob::knockback`. ## What changes - `Mob::damage_with` answers `sulfur_cube::immune_to(source)` (true) for a cube with a block that only took a knock; the tag is a named function now (`immune_to`). - `launch` takes the effect scale (1.0 for the blow's own push, `power * 0.25` for an extra one); `sulfur_cube::knockback` takes the effect power. - `Mob::knockback_effect(power, xd, zd, source, damage)`: a cube with a block and a causing entity goes through its own knockback, anything else through `Mob::knockback` as before. `attack_mob` uses it for the player's sprint and Knockback push. ## Verification - `an_effect_push_is_a_fraction_of_the_blows_own`: a sprint push (power 0.5) is 0.125 of the blow's own on every axis, a Knockback II push 0.25, the factors the issue's table shows (0.66 → 0.7425 → 0.825 is x1, x1.125, x1.25). - The existing immune-tag test now expects the true answer vanilla gives (health is still unchanged); 275 `horizon-client` `mobs::` tests pass, clippy and rustfmt are clean for the changed files except the existing `needless_borrow` in `horizon-world`. I did not run `tools/test_server_knockback_parity.py` (needs the vanilla jar and a newer Python); the issue's numbers are the cases to compare, and CI runs it. ## Not done - The sweep neighbours (`game/mace.rs`), the spear (`game/spear.rs`) and `MobEvent::Knockback` (a goat's ram, a mob's spear) still call `Mob::knockback`, so they do not reach the cube's override. Only the player's melee push is routed here. - #6113 (the cube's knockback resistance is -1 in vanilla) is a separate cause and not touched. 🤖 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 06:24:45 +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#6673
No description provided.