Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.