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

What I am trying to do is when ever a player gets hurt I would like for it to play a custom sound rather than the default hurt sound. I have it sort of working for when the player gets hurt, but when other players get hurt it still plays the regular hurt sounds. I have used the PlaySoundAtEntityEvent to change the sound for the player so I would assume there is an event for changing sounds that are not played at the entity.

  • Author

I know how to make a resource pack, but the thing is, is that I want the changed sound to be toggleable so that it can either be the default sound or the changed sound.

  • Author

So instead of doing that I used the PlaySoundEvent and tested that if the sound name was game.player.hurt, I would change the result to a different PositionSound.

This is the code I used:

 

 

@SubscribeEvent

public void soundPlay(PlaySoundEvent e)

{

if (e.name.equals("game.player.hurt") || e.name.equals("game.player.die") || e.name.equals("game.player.hurt.fall.big") || e.name.equals("game.player.hurt.fall.small"))

{

e.result = PositionedSoundRecord.create(new ResourceLocation(MODID + ":game.player.classic.hurt") (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);

}

}

 

 

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.