mojira.dev
MC-248487

The sounds of some non-player entities destroying blocks aren't controlled by the "Blocks" sound slider

The Bug:

The sounds of some non-player entities destroying blocks aren't controlled by the "Blocks" sound slider and are instead controlled by the "Hostile Creatures" sound slider. 

Any action that is created through an entity doing something that results in blocks being changed, is normally controlled by the "Blocks" sound slider. For example, the sounds of villagers opening doors, players applying wax to copper, and sheeps eating grass blocks, are all controlled by the "Blocks" sound slider as they should be, because the blocks have changed in some way as a result of the entities' actions.

Below I've constructed a table that highlights these errors.

 

Sound

Current Assigned Sound Slider

Expected Assigned Sound Slider

Non-player entities attacking wooden doors

Hostile Creatures

Blocks

Non-player entities breaking wooden doors

Hostile Creatures

Blocks

Non-player entities attacking iron doors

Hostile Creatures

Blocks

Withers breaking blocks

Hostile Creatures

Blocks

Non-player entities stomping on turtle eggs

Hostile Creatures

Blocks

h3. Steps to Reproduce:

  1. Navigate to the "Music & Sounds" settings menu.

  2. Turn the "Blocks" sound slider to "OFF".

  3. Turn every other sound slider to "100%".

  4. Exit this menu and produce any of the affected sounds as listed above.

  5. Take note as to whether or not the sounds of some non-player entities destroying blocks can be heard, (are controlled by the "Hostile Creatures" sound slider instead of the "Blocks" sound slider).

Observed Behavior:

The sounds aren't controlled by the "Blocks" sound slider and are instead controlled by the "Hostile Creatures" sound slider.

Expected Behavior:

All sounds of non-player entities destroying blocks as listed above would be controlled by the "Blocks" sound slider. The reason why the affected sounds should be controlled by the "Blocks" sound slider is that the blocks are changed in some way as a result of the entities' actions, thus should be controlled by the "Blocks" sound slider.

Code Analysis:

Code analysis by @unknown can be found below.

The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.

net.minecraft.client.renderer.LevelRenderer.java

public class LevelRenderer implements ResourceManagerReloadListener, AutoCloseable {
   ...
   public void levelEvent(Player &p, int $i0, BlockPos $bp, int $i1) {
      ...
      switch($i0) {
      ...
      case 1019:
         this.level.playLocalSound($bp, SoundEvents.ZOMBIE_ATTACK_WOODEN_DOOR, SoundSource.HOSTILE, 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
         break;
      case 1020:
         this.level.playLocalSound($bp, SoundEvents.ZOMBIE_ATTACK_IRON_DOOR, SoundSource.HOSTILE, 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
         break;
      case 1021:
         this.level.playLocalSound($bp, SoundEvents.ZOMBIE_BREAK_WOODEN_DOOR, SoundSource.HOSTILE, 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
         break;
      case 1022:
         this.level.playLocalSound($bp, SoundEvents.WITHER_BREAK_BLOCK, SoundSource.HOSTILE, 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
         break;
      ...

net.minecraft.world.entity.monster.Zombie.java

public class Zombie extends Monster {
   ...
   class ZombieAttackTurtleEggGoal extends RemoveBlockGoal {
      ...
      public void playDestroyProgressSound(LevelAccessor $la, BlockPos $bp) {
         $la.playSound((Player)null, $bp, SoundEvents.ZOMBIE_DESTROY_EGG, SoundSource.HOSTILE, 0.5F, 0.9F + Zombie.this.random.nextFloat() * 0.2F);
      }
      ...

If we look at the above classes, we can see that the affected sounds are sourced from SoundSource.HOSTILE, otherwise known as the "Hostile Creatures" sound slider.

Linked issues

Comments 1

Actions by hostile mobs should be in hostile mob sounds. If a player lowers their blocks slider (for example because of a noisy redstone machine nearby) it's better if they can still notice when hostile mobs attack!

Avoma

(Unassigned)

Confirmed

Sound, UI

1.18.1, 22w05a, 22w06a, 1.18.2 Pre-release 1, 1.18.2, ..., 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20.1

Retrieved