[PR #5155] [MERGED] Sulfur cubes: a blow turns the launch by where the attacker aims #6105

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5155
Author: @xFedeT
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: fix/sulfur-cube-hit-angles


📝 Commits (6)

  • 3bb2c7d Sulfur cubes: a blow turns the launch by where the attacker aims
  • 6b333b2 Merge remote-tracking branch 'origin/main' into fix/sulfur-cube-hit-angles
  • f684653 Sulfur cubes: the launch follows any causing entity, and the tags vanilla checks
  • 23f6145 Merge remote-tracking branch 'origin/main' into fix/sulfur-cube-hit-angles
  • 645ee4c A projectile knocks a mob the way it travelled
  • 138b02a Merge remote-tracking branch 'origin/main' into fix/sulfur-cube-hit-angles

📊 Changes

6 files changed (+388 additions, -55 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+19 -23)
📝 crates/horizon-client/src/game/mace.rs (+32 -0)
📝 crates/horizon-client/src/game/trident.rs (+4 -1)
📝 crates/horizon-client/src/mobs.rs (+47 -3)
📝 crates/horizon-client/src/mobs/sulfur_cube.rs (+284 -26)
📝 tools/port_map/game2-003.tsv (+2 -2)

📄 Description

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

Refs #3513 (rows SulfurCube.applyHorizontalHitAngleScale and SulfurCube.applyVerticalHitAnglePowerTransfer).

What and why

A sulfur cube holding a block is knocked about by blows (SulfurCube.knockback). Vanilla turns the launch by where the attacker aims, in two steps Horizon left out, before the position-based rotation it already had:

  • applyHorizontalHitAngleScale(1.6, ...): the knock's direction is turned by the angle between the attacker's view and the line from their eye to the cube's centre, times 1.6. Hitting the cube off-centre sends it sideways.
  • applyVerticalHitAnglePowerTransfer(0.5, ...): power moves between the horizontal and the vertical launch by where the view crosses the cube between its top and bottom (Mth.clampedMap). Hitting the top drives it down and forward, the bottom lifts it.

Horizon took the attacker to aim at the cube's centre, so both did nothing.

The change

  • sulfur_cube.rs: launch (what the knock adds to the movement) does vanilla's three steps in its order and its float arithmetic: the two above, then the rotation by the feet-to-feet angle with the ratio clamp, the sqrt(damage) multiplier, the resistance, 0.4, the clamp to ±128 and the 1.2 on the vertical. Vec2.rotate goes through Mth's sine tables (geometry::trig) and the angles through Math.atan2; a zero-length direction pushes nothing, as Vec3.normalize does.
  • Mob::attacker_aim / Aim: the eye position, view direction (calculateViewVector(xRot, yRot)) and feet of source.getEntity(), given by Game::attacker_aim for the player and for any mob, and set when the blow is dealt: the player's melee, spear and mace blows (hurt_by_player), a mob's attack (mob_hits_mob), arrows and thrown items by their owner, and the trident. The rotation by height uses the entity's feet, not the projectile's position, as applyVerticalPositionAnglePowerRotation does.
  • A projectile knocks the way it travelled: LivingEntity.dealDefaultKnockback takes the direction from Projectile.calculateHorizontalHurtKnockbackDirection (the projectile's horizontal motion, negated), not from its position. Mob::projectile_motion carries it from where an arrow, a thrown item or the trident's hit is dealt, for the cube's two branches and for every other mob's default knockback.
  • hurtServer as vanilla has it: a blow of a type tagged no_knockback (explosions, falls) does not knock the cube, and a blow with no causing entity goes through LivingEntity.knockback(0.4, ...) instead of SulfurCube.knockback.
  • Port map: both rows are port.

Vanilla reference

SulfurCube.knockback, applyHorizontalHitAngleScale, applyVerticalHitAnglePowerTransfer, applyVerticalPositionAnglePowerRotation (SulfurCube.java 769-850), Vec2.rotate, Mth.clampedMap, Vec3.normalize. Read before changing; the old code applied the powers' rotation to the unturned ones and normalised with a floor of 1e-4 instead of vanilla's 1e-5 cut-off.

How it was checked

  • launch_tests::the_launch_follows_the_vanilla_helpers: the bodies of the three vanilla helpers and the end of knockback were run on the real Vec2, Vec3 and Mth classes of the 26.3 jar for six blows (a melee hit from different heights and sides, one with no aim, and two from an arrow with its motion whose owner stands elsewhere), and the Rust result matches to 1e-9 on each axis.
  • tools/parity.py mob_ai arrow damage_source living_hurt server_knockback mob_attributes: all six pass with the projectile knock direction below, which changes how every mob is knocked by an arrow.
  • pr_ready --quick: fmt, clippy, tests pass; parity harnesses beyond those above are left to CI.

No screenshots: the difference is a number of tenths of a block per tick in the cube's launch, which the test pins.

🤖 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/5155 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/sulfur-cube-hit-angles` --- ### 📝 Commits (6) - [`3bb2c7d`](https://github.com/horizon-rust/horizon/commit/3bb2c7d3e428fff2c2df4e038e84490894a53583) Sulfur cubes: a blow turns the launch by where the attacker aims - [`6b333b2`](https://github.com/horizon-rust/horizon/commit/6b333b2754e4548a531181dffb9a1468e21c65ee) Merge remote-tracking branch 'origin/main' into fix/sulfur-cube-hit-angles - [`f684653`](https://github.com/horizon-rust/horizon/commit/f6846536588d2521f7e9310d41ccf114e52d385b) Sulfur cubes: the launch follows any causing entity, and the tags vanilla checks - [`23f6145`](https://github.com/horizon-rust/horizon/commit/23f6145aff1fc74121b9579c370d6f35e1ed22b2) Merge remote-tracking branch 'origin/main' into fix/sulfur-cube-hit-angles - [`645ee4c`](https://github.com/horizon-rust/horizon/commit/645ee4c5467b56ea68a4781c84e638ba58d2a630) A projectile knocks a mob the way it travelled - [`138b02a`](https://github.com/horizon-rust/horizon/commit/138b02a242c23f35786e3bf8fc84795fdcc267d2) Merge remote-tracking branch 'origin/main' into fix/sulfur-cube-hit-angles ### 📊 Changes **6 files changed** (+388 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+19 -23) 📝 `crates/horizon-client/src/game/mace.rs` (+32 -0) 📝 `crates/horizon-client/src/game/trident.rs` (+4 -1) 📝 `crates/horizon-client/src/mobs.rs` (+47 -3) 📝 `crates/horizon-client/src/mobs/sulfur_cube.rs` (+284 -26) 📝 `tools/port_map/game2-003.tsv` (+2 -2) </details> ### 📄 Description > 🤖 Opened by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally. Refs #3513 (rows `SulfurCube.applyHorizontalHitAngleScale` and `SulfurCube.applyVerticalHitAnglePowerTransfer`). ## What and why A sulfur cube holding a block is knocked about by blows (`SulfurCube.knockback`). Vanilla turns the launch by where the attacker aims, in two steps Horizon left out, before the position-based rotation it already had: - `applyHorizontalHitAngleScale(1.6, ...)`: the knock's direction is turned by the angle between the attacker's view and the line from their eye to the cube's centre, times 1.6. Hitting the cube off-centre sends it sideways. - `applyVerticalHitAnglePowerTransfer(0.5, ...)`: power moves between the horizontal and the vertical launch by where the view crosses the cube between its top and bottom (`Mth.clampedMap`). Hitting the top drives it down and forward, the bottom lifts it. Horizon took the attacker to aim at the cube's centre, so both did nothing. ## The change - `sulfur_cube.rs`: `launch` (what the knock adds to the movement) does vanilla's three steps in its order and its float arithmetic: the two above, then the rotation by the feet-to-feet angle with the ratio clamp, the `sqrt(damage)` multiplier, the resistance, `0.4`, the clamp to ±128 and the `1.2` on the vertical. `Vec2.rotate` goes through `Mth`'s sine tables (`geometry::trig`) and the angles through `Math.atan2`; a zero-length direction pushes nothing, as `Vec3.normalize` does. - `Mob::attacker_aim` / `Aim`: the eye position, view direction (`calculateViewVector(xRot, yRot)`) and feet of `source.getEntity()`, given by `Game::attacker_aim` for the player and for any mob, and set when the blow is dealt: the player's melee, spear and mace blows (`hurt_by_player`), a mob's attack (`mob_hits_mob`), arrows and thrown items by their owner, and the trident. The rotation by height uses the entity's feet, not the projectile's position, as `applyVerticalPositionAnglePowerRotation` does. - A projectile knocks the way it travelled: `LivingEntity.dealDefaultKnockback` takes the direction from `Projectile.calculateHorizontalHurtKnockbackDirection` (the projectile's horizontal motion, negated), not from its position. `Mob::projectile_motion` carries it from where an arrow, a thrown item or the trident's hit is dealt, for the cube's two branches and for every other mob's default knockback. - `hurtServer` as vanilla has it: a blow of a type tagged `no_knockback` (explosions, falls) does not knock the cube, and a blow with no causing entity goes through `LivingEntity.knockback(0.4, ...)` instead of `SulfurCube.knockback`. - Port map: both rows are `port`. ## Vanilla reference `SulfurCube.knockback`, `applyHorizontalHitAngleScale`, `applyVerticalHitAnglePowerTransfer`, `applyVerticalPositionAnglePowerRotation` (`SulfurCube.java` 769-850), `Vec2.rotate`, `Mth.clampedMap`, `Vec3.normalize`. Read before changing; the old code applied the powers' rotation to the unturned ones and normalised with a floor of 1e-4 instead of vanilla's 1e-5 cut-off. ## How it was checked - `launch_tests::the_launch_follows_the_vanilla_helpers`: the bodies of the three vanilla helpers and the end of `knockback` were run on the real `Vec2`, `Vec3` and `Mth` classes of the 26.3 jar for six blows (a melee hit from different heights and sides, one with no aim, and two from an arrow with its motion whose owner stands elsewhere), and the Rust result matches to 1e-9 on each axis. - `tools/parity.py mob_ai arrow damage_source living_hurt server_knockback mob_attributes`: all six pass with the projectile knock direction below, which changes how every mob is knocked by an arrow. - `pr_ready --quick`: fmt, clippy, tests pass; parity harnesses beyond those above are left to CI. No screenshots: the difference is a number of tenths of a block per tick in the cube's launch, which the test pins. 🤖 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:11:42 +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#6105
No description provided.