Wiki 9Minecraft Wiki 9Minecraft
Snassets Library General Wiki › Guides › Reference SnAssets Sounds in Your Custom Mod

Reference SnAssets Sounds in Your Custom Mod

Adding Sound Dependencies

To use SnAssets Library sounds in your mod, first declare it as a dependency in your mod's configuration file (fabric.mod.json, mods.toml, or equivalent for your loader). This ensures the library loads before your mod attempts to reference its assets.

Pointing to SnAssets Audio

In your mod's sounds.json file, create sound entries that reference the library's namespace. Use the format:

`json

"your_sound_name": {

"sounds": ["snassets:path/to/sound"]

}

`

Replace path/to/sound with the actual audio file path within SnAssets. For example, to use a gunshot sound:

`json

"gunshot": {

"sounds": ["snassets:weapons/rifle/fire"]

}

`

Playing Your Sound

Once registered, play the sound in your code using your mod's sound event system. The SnAssets Library handles the actual audio file loading—you only reference it by namespace and path.

This approach keeps your mod's file size down and ensures all mods using SnAssets share the same high-quality audio files rather than duplicating them.