Skip to content

Instantly share code, notes, and snippets.

@robere2
Last active April 14, 2018 00:45
Show Gist options
  • Save robere2/1d03efc71c78235b75fb73c124e1f732 to your computer and use it in GitHub Desktop.
Save robere2/1d03efc71c78235b75fb73c124e1f732 to your computer and use it in GitHub Desktop.
1.8.9 Sounds System Example
public void playFireSound() {
playSound("gun.shotgun.fire");
}
public void playReloadSound() {
playSound("gun.shotgun.reload");
}
/**
* Play sound
* @param name The name of the sound (not the path to the sound)
*/
public void playSound(final String name) {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation(Reference.MOD_ID, name), 1.0F));
}
{
"gun.shotgun.fire": {
"sounds":["gun/shotgun/fire"],
"category": "player"
},
"gun.shotgun.reload": {
"sounds":["gun/shotgun/reload"],
"category": "player"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment