The bug
Ambiance / cave music can play far away from the player. This way the player might hear it less often than it should appear.
Report history
This report used to include in-game and title music as well. These were fixed in previous versions.
Code analysis
Based on 1.11 decompiled using MCP 9.35 rc1
The problem is that the method net.minecraft.client.multiplayer.WorldClient.playMoodSoundAndCheckLight(int, int, Chunk)
, which plays the ambient cave sound, is called with chunk coordinates of all visible chunks and only tests if the position tested is at least 2 meters away. This means the position can be hundreds of blocks away.
Example fix (1.11)
protected void playMoodSoundAndCheckLight(int p_147467_1_, int p_147467_2_, Chunk chunkIn)
{
super.playMoodSoundAndCheckLight(p_147467_1_, p_147467_2_, chunkIn);
if (this.ambienceTicks == 0)
{
this.updateLCG = this.updateLCG * 3 + 1013904223;
int i = this.updateLCG >> 2;
int j = i & 15;
int k = i >> 8 & 15;
int l = i >> 16 & 255;
BlockPos blockpos = new BlockPos(j + p_147467_1_, l, k + p_147467_2_);
IBlockState iblockstate = chunkIn.getBlockState(blockpos);
j = j + p_147467_1_;
k = k + p_147467_2_;
// Old code
//if (iblockstate.getMaterial() == Material.AIR && this.getLight(blockpos) <= this.rand.nextInt(8) && this.getLightFor(EnumSkyBlock.SKY, blockpos) <= 0 && this.mc.player != null && this.mc.player.getDistanceSq((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D) > 4.0D)
//{
// this.playSound((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, SoundEvents.AMBIENT_CAVE, SoundCategory.AMBIENT, 0.7F, 0.8F + this.rand.nextFloat() * 0.2F, false);
// this.ambienceTicks = this.rand.nextInt(12000) + 6000;
//}
if (this.mc.player != null) {
double distanceToPlayerSquared = this.mc.player.getDistanceSq((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D);
// The player cannot hear the sound if it is played more than 15 (sqrt(255)) blocks away
if (distanceToPlayerSquared > 4.0 && distanceToPlayerSquared <= 255.0 && iblockstate.getMaterial() == Material.AIR && this.getLight(blockpos) <= this.rand.nextInt(8) && this.getLightFor(EnumSkyBlock.SKY, blockpos) <= 0)
{
this.playSound((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, SoundEvents.AMBIENT_CAVE, SoundCategory.AMBIENT, 0.7F, 0.8F + this.rand.nextFloat() * 0.2F, false);
this.ambienceTicks = this.rand.nextInt(12000) + 6000;
}
}
}
}
Linked issues
is duplicated by 25
relates to 3
Comments 108
Using /playsound isn't really the same since you're basically manually telling the game to play the music instead of letting it happen naturally.
Can confirm, also this bug report is a duplicate of MC-91610.
@@unknown: MC-91610 is about not having any sound at all, this is only about having no automatic background music but rest of sounds.
Confirm, but its working only in survival without night vision and happens pretty rare, also in minecraft 1.2.1 (ios), its still missed
Someone in MC-139255 reported that this is an issue in 18w45a again. Can anyone confirm this?
Made a quick test world with two meters of dark space beneath a flat layer of stone, perfect to provoce cave ambient sounds. Tested it in 1.13.2, heard the first one after 10 min. Then tested it in 18w45a, none after 30 min. They might really be broken again.
I did my test again, and it turns out that cave ambiance just doesn't play at all in 18w46a. Probably has to do with the new light engine changes, but that's just a guess.
Can confirm. Most likely due to sound rewrites.