[PR #4837] [MERGED] mobs: play slime and magma cube attack sound only when hurtServer succeeds #5883

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4837
Author: @mulareal
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix-slime-attack-sound-4569


📝 Commits (1)

  • f554aa5 mobs: play slime and magma cube attack sound only when hurtServer succeeds

📊 Changes

5 files changed (+124 additions, -13 deletions)

View changed files

📝 crates/horizon-client/examples/probe/mob_ai_probe.rs (+2 -0)
📝 crates/horizon-client/src/game/creatures.rs (+24 -0)
📝 crates/horizon-client/src/game/lan_mobs.rs (+1 -0)
📝 crates/horizon-client/src/mobs.rs (+8 -0)
📝 crates/horizon-client/src/mobs/cube.rs (+89 -13)

📄 Description

🤖 Opened by mulareal's AI agent (Antigravity, Gemini), not by mulareal personally.

What

Slimes and magma cubes play their attack sound once per landed hit instead of every tick while touching the player. Fixes #4569.

Why

  • cube::ai_step emitted MobEvent::AttackPlayer and MobEvent::Sound(entity.slime.attack, ...) on every tick that a cube mob overlapped the player's melee range, without waiting to see whether hurtServer succeeded (AbstractCubeMob.dealDamage).
  • During the player's 10-tick hurt immunity cooldown (hurt_player_from returning false), the attack sound still played 20 times per second and consumed two random pitch draws each tick.
  • cube::ai_step also skipped the !m.no_ai, doTeamsAllowDamage, and hasLineOfSight checks that AbstractCubeMob.dealDamage runs before hurtServer on a player target.

Fix

  • Gate player contact damage in cube::ai_step (crates/horizon-client/src/mobs/cube.rs) on !m.no_ai, teams_allow_damage, and m.sees(w, Who::Player), and emit MobEvent::CubeHurtPlayer.
  • Handle MobEvent::CubeHurtPlayer in Game::handle_mob_events (crates/horizon-client/src/game/creatures.rs), acts_on_player (crates/horizon-client/src/game/lan_mobs.rs), and mob_ai_probe.rs, playing entity.slime.attack and advancing the cube's random pitch only when hurt_player_from returns true.

Checked

  • cargo fmt --all -- --check
  • cargo clippy -p horizon-client --bins --tests -- -D warnings
  • cargo test -p horizon-client --lib a_cube_touching_a_player_defers_its_attack_sound_to_hurt_server
  • cargo check -p horizon-client --example client_probe
  • Manual in-game check: summoned a slime in survival mode and verified entity.slime.attack plays only on landed hits rather than every contact tick.
Check Result
Scope ✅ 5 files, +124 −13
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed
rustfmt ✅
clippy (horizon-client) ✅
tests: horizon-client ✅ 1168 passed
doc tests ✅ 0 passed
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses

🤖 Generated with Antigravity


🔄 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/4837 **Author:** [@mulareal](https://github.com/mulareal) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix-slime-attack-sound-4569` --- ### 📝 Commits (1) - [`f554aa5`](https://github.com/horizon-rust/horizon/commit/f554aa5a6c94c659678bc036b0fd56d258479ccd) mobs: play slime and magma cube attack sound only when hurtServer succeeds ### 📊 Changes **5 files changed** (+124 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/mob_ai_probe.rs` (+2 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+24 -0) 📝 `crates/horizon-client/src/game/lan_mobs.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs.rs` (+8 -0) 📝 `crates/horizon-client/src/mobs/cube.rs` (+89 -13) </details> ### 📄 Description > 🤖 Opened by mulareal's AI agent (Antigravity, Gemini), not by mulareal personally. ## What Slimes and magma cubes play their attack sound once per landed hit instead of every tick while touching the player. Fixes #4569. ## Why - `cube::ai_step` emitted `MobEvent::AttackPlayer` and `MobEvent::Sound(entity.slime.attack, ...)` on every tick that a cube mob overlapped the player's melee range, without waiting to see whether `hurtServer` succeeded (`AbstractCubeMob.dealDamage`). - During the player's 10-tick hurt immunity cooldown (`hurt_player_from` returning `false`), the attack sound still played 20 times per second and consumed two random pitch draws each tick. - `cube::ai_step` also skipped the `!m.no_ai`, `doTeamsAllowDamage`, and `hasLineOfSight` checks that `AbstractCubeMob.dealDamage` runs before `hurtServer` on a player target. ## Fix - Gate player contact damage in `cube::ai_step` (`crates/horizon-client/src/mobs/cube.rs`) on `!m.no_ai`, `teams_allow_damage`, and `m.sees(w, Who::Player)`, and emit `MobEvent::CubeHurtPlayer`. - Handle `MobEvent::CubeHurtPlayer` in `Game::handle_mob_events` (`crates/horizon-client/src/game/creatures.rs`), `acts_on_player` (`crates/horizon-client/src/game/lan_mobs.rs`), and `mob_ai_probe.rs`, playing `entity.slime.attack` and advancing the cube's random pitch only when `hurt_player_from` returns `true`. ## Checked - `cargo fmt --all -- --check` - `cargo clippy -p horizon-client --bins --tests -- -D warnings` - `cargo test -p horizon-client --lib a_cube_touching_a_player_defers_its_attack_sound_to_hurt_server` - `cargo check -p horizon-client --example client_probe` - Manual in-game check: summoned a slime in survival mode and verified `entity.slime.attack` plays only on landed hits rather than every contact tick. | Check | Result | |---|---| | Scope | ✅ 5 files, +124 −13 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed | | rustfmt | ✅ | | clippy (`horizon-client`) | ✅ | | tests: horizon-client | ✅ 1168 passed | | doc tests | ✅ 0 passed | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | 🤖 Generated with [Antigravity](https://antigravity.google) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:40 +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#5883
No description provided.