Posted August 15, 201510 yr 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.
August 15, 201510 yr 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.
August 15, 201510 yr 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.