[PR #4502] [MERGED] Fixes the PiglinBruteAi.playActivitySound and maybePlayActivitySound rows in the port ledger. (No issue.) #5660

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

📋 Pull Request Information

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

Base: main ← Head: fix/brute-angry-sound


📝 Commits (2)

  • 971e8a9 Growl when a piglin brute starts a fight
  • 587b85d Merge remote-tracking branch 'origin/main' into fix-4502

📊 Changes

2 files changed (+119 additions, -17 deletions)

View changed files

📝 crates/horizon-client/src/mobs/ai.rs (+1 -1)
📝 crates/horizon-client/src/mobs/piglin.rs (+118 -16)

📄 Description

Fixes the PiglinBruteAi.playActivitySound and maybePlayActivitySound rows in the port ledger. (No issue.) PiglinBruteAi.updateActivity switches a brute between FIGHT and IDLE and, when the activity changes, voices entity.piglin_brute.angry; maybePlayActivitySound draws level.getRandom().nextFloat() < 0.0125 every tick and then plays that same FIGHT-gated sound, so a brute growls once as the fight starts and about once per 80 ticks while it lasts. Horizon had the activity machinery and the sound for piglins only — the gates in mobs/ai.rs cover Piglin | Hoglin, so a brute's activity stayed Idle and it never made a sound. This adds the brute to that path: the shared update_activity dispatches the sound by species, the FIGHT-gated play_brute_sound and the unconditional-roll maybe_play_brute_sound mirror vanilla's two methods, and piglin::ai_step runs them after the goals, where PiglinBrute.customServerAiStep does. The level random is threaded through so the roll draws from the same stream at the same point — drawing only while fighting would desync it and change the brute's AI. The piglin's own entity.piglin.angry is untouched. What is proven: cargo test -p horizon-client --lib mobs::piglin::brute_sound_tests → 2 passed on a build box, including the case that needs the prepared 26.3 data: a brute with a target voices exactly entity.piglin_brute.angry, losing the target is silent, and a piglin still voices entity.piglin.angry. A second test steps 2000 ticks against a control stream and asserts a sound appears exactly when the roll hits during a fight — pinning both the unconditional draw and the FIGHT gate. What is not proven: the sound has not been heard in a game; the check for that is a summoned brute, one hit, and entity.piglin_brute.angry appearing in the agent's heard map once at the start of the fight. pr_ready was not run on this branch, so CI's verify is the workspace check.
Two corrections from an independent read of the jar, added after opening:

  • Piglins do not use maybePlayActivitySound at all: PiglinAi has no such method, and a piglin picks its transition sound inside getSoundForCurrentActivity (angry, retreat, admiring, celebrate, jealous, ambient). So the "0.0125 every tick" roll is brute-only, and this PR adds a mechanic that did not exist for any mob rather than extending a piglin one.
  • The first test's world half needs the prepared 26.3 data; without it with_test_world does not run the closure and the test passes vacuously. It did run for real on the build box, but on a machine without .local/ it proves nothing — the same caveat as every test in that file.
  • Also worth knowing, not a regression: vanilla calls brute.setAggressive(hasMemoryValue(ATTACK_TARGET)) right after the sound; Horizon's aggression is owned by the melee goal instead, so that line has no counterpart here.

🔄 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/4502 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/brute-angry-sound` --- ### 📝 Commits (2) - [`971e8a9`](https://github.com/horizon-rust/horizon/commit/971e8a90f07e7708b79b93d1e53cbc21a053c4ff) Growl when a piglin brute starts a fight - [`587b85d`](https://github.com/horizon-rust/horizon/commit/587b85d675440371477e59971403f0d68a83908a) Merge remote-tracking branch 'origin/main' into fix-4502 ### 📊 Changes **2 files changed** (+119 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/ai.rs` (+1 -1) 📝 `crates/horizon-client/src/mobs/piglin.rs` (+118 -16) </details> ### 📄 Description Fixes the `PiglinBruteAi.playActivitySound` and `maybePlayActivitySound` rows in the port ledger. (No issue.) `PiglinBruteAi.updateActivity` switches a brute between FIGHT and IDLE and, when the activity changes, voices `entity.piglin_brute.angry`; `maybePlayActivitySound` draws `level.getRandom().nextFloat() < 0.0125` **every tick** and then plays that same FIGHT-gated sound, so a brute growls once as the fight starts and about once per 80 ticks while it lasts. Horizon had the activity machinery and the sound for piglins only — the gates in `mobs/ai.rs` cover `Piglin | Hoglin`, so a brute's activity stayed `Idle` and it never made a sound. This adds the brute to that path: the shared `update_activity` dispatches the sound by species, the FIGHT-gated `play_brute_sound` and the unconditional-roll `maybe_play_brute_sound` mirror vanilla's two methods, and `piglin::ai_step` runs them after the goals, where `PiglinBrute.customServerAiStep` does. The level random is threaded through so the roll draws from the same stream at the same point — drawing only while fighting would desync it and change the brute's AI. The piglin's own `entity.piglin.angry` is untouched. **What is proven:** `cargo test -p horizon-client --lib mobs::piglin::brute_sound_tests` → 2 passed on a build box, including the case that needs the prepared 26.3 data: a brute with a target voices exactly `entity.piglin_brute.angry`, losing the target is silent, and a piglin still voices `entity.piglin.angry`. A second test steps 2000 ticks against a control stream and asserts a sound appears exactly when the roll hits during a fight — pinning both the unconditional draw and the FIGHT gate. **What is not proven:** the sound has not been heard in a game; the check for that is a summoned brute, one hit, and `entity.piglin_brute.angry` appearing in the agent's `heard` map once at the start of the fight. `pr_ready` was not run on this branch, so CI's `verify` is the workspace check. Two corrections from an independent read of the jar, added after opening: - Piglins do **not** use `maybePlayActivitySound` at all: `PiglinAi` has no such method, and a piglin picks its transition sound inside `getSoundForCurrentActivity` (angry, retreat, admiring, celebrate, jealous, ambient). So the "0.0125 every tick" roll is brute-only, and this PR adds a mechanic that did not exist for any mob rather than extending a piglin one. - The first test's world half needs the prepared 26.3 data; without it `with_test_world` does not run the closure and the test passes vacuously. It did run for real on the build box, but on a machine without `.local/` it proves nothing — the same caveat as every test in that file. - Also worth knowing, not a regression: vanilla calls `brute.setAggressive(hasMemoryValue(ATTACK_TARGET))` right after the sound; Horizon's aggression is owned by the melee goal instead, so that line has no counterpart here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:14:09 +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#5660
No description provided.