Jump to content

Attenuation Distance not applicable for sounds played by server


Recommended Posts

Posted (edited)

Hello, after spending lots of time investigating why attenuation distance does not work, I figured out that it only works when the sound is played on client. Is this intentional?

Edited by poopoodice
Posted (edited)

I've simplified my problem into a smaller area:

https://bitbucket.org/poopoodice/ava/src/1.16.x/src/main/java/poopoodice/ava/items/miscs/TestItem.java

    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity player, Hand handIn)
    {
        if (worldIn.isRemote())
            player.world.playSound(player, 0, 1, 0, AVASounds.GENERIC_GRENADE_EXPLODE, SoundCategory.PLAYERS, 1.0F, 1.0F);
        if (!worldIn.isRemote())
            player.world.playSound(null, 0, 0, 0, AVASounds.GENERIC_GRENADE_EXPLODE, SoundCategory.PLAYERS, 1.0F, 1.0F);
        worldIn.playSound(player, 0, 0, 0, AVASounds.GENERIC_GRENADE_EXPLODE, SoundCategory.PLAYERS, 1.0F, 1.0F);
        return super.onItemRightClick(worldIn, player, handIn);
    }

My test result:

1. The first World#playSound

-> result in the attenuation distance is applied (can be heard from 16+ blocks away)

2. The second World#playSound

-> result in the attenuation distance is not applied (cannot be heard from 16+ blocks away)

3. The third World#playSound

-> result in the attenuation distance is applied

 

It seems like playing sound on server world will only send to the players that are within the radius of max(16.0F, volume * 16.0F), and for other vanilla sounds that uses greater attenuation distance for example ravager's roar, it is played on both sides which will work.

 

If I can only play the sound on server while the attenuation effect to be applied, the only way I can think of is send packets to all players, is that necessary or is there an alternative way of doing it?

 

Edit: Sending Customs packets works.

Edited by poopoodice

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.