[PR #7589] Sound a killer bunny's bite #7699

Open
opened 2026-11-03 07:22:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7589
Author: @MSedgeMC
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/killer-bunny-bite-sound


📝 Commits (3)

  • 09d1aaf fix: a killer bunny's bite sounds
  • 280a35a test: the killer bunny's bite sound, its two draws and its pitch
  • dfb56a3 port_map: game-013's rabbit attack sound is played

📊 Changes

3 files changed (+93 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/mobs/ai.rs (+4 -0)
📝 crates/horizon-client/src/mobs/rabbit.rs (+88 -0)
📝 tools/port_map/game-013.tsv (+1 -1)

📄 Description

A killer bunny bites with entity.rabbit.attack in vanilla; here it bit in silence.

Vanilla

Mob.doHurtTarget (javap -p -c -constants -cp /tmp/cj net.minecraft.world.entity.Mob):

 60: invokevirtual #1780  // Entity.hurtServer:(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/damagesource/DamageSource;F)Z
 67: ifeq          126
 ...
123: invokevirtual #1804  // Method playAttackSound:()V
126: ... ireturn

the hit landed, so playAttackSound(). Rabbit.playAttackSound (...net.minecraft.world.entity.animal.rabbit.Rabbit):

  0: getVariant
  4: getstatic #322   // Field Rabbit$Variant.EVIL
  7: if_acmpne     42                       // any other variant: nothing
 11: getstatic #481   // SoundEvents.RABBIT_ATTACK
 14: fconst_1                                // volume 1.0
 19: RandomSource.nextFloat
 24: RandomSource.nextFloat
 33: fsub  34: ldc 0.2f  36: fmul  37: fconst_1  38: fadd   // pitch
 39: invokevirtual #272 // playSound:(Lnet/minecraft/sounds/SoundEvent;FF)V

and SoundEvents.RABBIT_ATTACK registers the id entity.rabbit.attack (SoundEvents.<clinit>, ldc "entity.rabbit.attack" → putstatic RABBIT_ATTACK).

Two details the bytecode fixes:

  • the pitch is an argument of playSound, so its two nextFloat draws are made before Entity.playSound looks at isSilent — a silent killer bunny still pays them;
  • the base is the override's plain 1.0, not getVoicePitch's baby-aware 1.5, so a baby killer bunny is pitched like an adult.

What Horizon got wrong

mobs/ai.rs::do_hurt_target ends with the same hook, and the creaking's, the panda's and the axolotl's playAttackSound arms sit there:

// Mob.doHurtTarget ends with playAttackSound once the hit landed.
if super::creaking::is_creaking(m) {
    m.voice("entity.creaking.attack", cx.events);
}

There was no rabbit arm, so a killer bunny (which mobs/rabbit.rs does implement: variant EVIL 99, set_variant, the bite goals, +5 attack damage) bit in silence.

Proven

  • the_killer_bunny_bites_with_its_own_sound: the pitch equals the one a copy of the mob's random gives after vanilla's two nextFloat draws; a baby killer bunny keeps the 1.0 base; a silent killer bunny makes the same two draws and emits nothing; a brown rabbit emits nothing and draws nothing.
  • With the silence check moved before the draws (the natural mistake) the silent case fails: the mob's next nextInt(1000) is 704 where vanilla's two draws leave 662.
  • cargo test -p horizon-client-lib --lib attack_sound_tests passes; cargo clippy -q -p horizon-client-lib --lib and rustfmt --edition 2024 --check are clean.

Not proven

  • entity.rabbit.attack is played through MobEvent::Sound and resolved by the sound engine; that the file ships in a given resource pack was not checked here.
  • Nothing was heard in a running client, and the MeleeAttack goal's own path was not exercised end to end (the unit test calls attack_sound directly).

🔄 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/7589 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/killer-bunny-bite-sound` --- ### 📝 Commits (3) - [`09d1aaf`](https://github.com/horizon-rust/horizon/commit/09d1aaf744f6ede30ef9ad65630b806c2c4f8022) fix: a killer bunny's bite sounds - [`280a35a`](https://github.com/horizon-rust/horizon/commit/280a35a7b694377e2727ae4bf7b82c2f9a7a3841) test: the killer bunny's bite sound, its two draws and its pitch - [`dfb56a3`](https://github.com/horizon-rust/horizon/commit/dfb56a37076dc840f7a27c06493496bbb637779d) port_map: game-013's rabbit attack sound is played ### 📊 Changes **3 files changed** (+93 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/ai.rs` (+4 -0) 📝 `crates/horizon-client/src/mobs/rabbit.rs` (+88 -0) 📝 `tools/port_map/game-013.tsv` (+1 -1) </details> ### 📄 Description A killer bunny bites with `entity.rabbit.attack` in vanilla; here it bit in silence. ## Vanilla `Mob.doHurtTarget` (`javap -p -c -constants -cp /tmp/cj net.minecraft.world.entity.Mob`): ``` 60: invokevirtual #1780 // Entity.hurtServer:(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/damagesource/DamageSource;F)Z 67: ifeq 126 ... 123: invokevirtual #1804 // Method playAttackSound:()V 126: ... ireturn ``` the hit landed, so `playAttackSound()`. `Rabbit.playAttackSound` (`...net.minecraft.world.entity.animal.rabbit.Rabbit`): ``` 0: getVariant 4: getstatic #322 // Field Rabbit$Variant.EVIL 7: if_acmpne 42 // any other variant: nothing 11: getstatic #481 // SoundEvents.RABBIT_ATTACK 14: fconst_1 // volume 1.0 19: RandomSource.nextFloat 24: RandomSource.nextFloat 33: fsub 34: ldc 0.2f 36: fmul 37: fconst_1 38: fadd // pitch 39: invokevirtual #272 // playSound:(Lnet/minecraft/sounds/SoundEvent;FF)V ``` and `SoundEvents.RABBIT_ATTACK` registers the id `entity.rabbit.attack` (`SoundEvents.<clinit>`, `ldc "entity.rabbit.attack"` → `putstatic RABBIT_ATTACK`). Two details the bytecode fixes: - the pitch is an **argument** of `playSound`, so its two `nextFloat` draws are made before `Entity.playSound` looks at `isSilent` — a silent killer bunny still pays them; - the base is the override's plain `1.0`, not `getVoicePitch`'s baby-aware `1.5`, so a baby killer bunny is pitched like an adult. ## What Horizon got wrong `mobs/ai.rs::do_hurt_target` ends with the same hook, and the creaking's, the panda's and the axolotl's `playAttackSound` arms sit there: ```rust // Mob.doHurtTarget ends with playAttackSound once the hit landed. if super::creaking::is_creaking(m) { m.voice("entity.creaking.attack", cx.events); } ``` There was no rabbit arm, so a killer bunny (which `mobs/rabbit.rs` does implement: variant `EVIL` 99, `set_variant`, the bite goals, +5 attack damage) bit in silence. ## Proven - `the_killer_bunny_bites_with_its_own_sound`: the pitch equals the one a copy of the mob's random gives after vanilla's two `nextFloat` draws; a baby killer bunny keeps the 1.0 base; a silent killer bunny makes the same two draws and emits nothing; a brown rabbit emits nothing and draws nothing. - With the silence check moved before the draws (the natural mistake) the silent case fails: the mob's next `nextInt(1000)` is **704** where vanilla's two draws leave **662**. - `cargo test -p horizon-client-lib --lib attack_sound_tests` passes; `cargo clippy -q -p horizon-client-lib --lib` and `rustfmt --edition 2024 --check` are clean. ## Not proven - `entity.rabbit.attack` is played through `MobEvent::Sound` and resolved by the sound engine; that the file ships in a given resource pack was not checked here. - Nothing was heard in a running client, and the `MeleeAttack` goal's own path was not exercised end to end (the unit test calls `attack_sound` directly). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7699
No description provided.