Jump to content

Recommended Posts

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.

Posted

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

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