Class RaccoonSoundProvider
- All Implemented Interfaces:
net.minecraft.data.DataProvider
- Direct Known Subclasses:
AutoSoundProvider,ManualModSoundProvider
sounds.json.
To see an example of usage head to ManualModSoundProvider or AutoModSoundProvider.
This class simplifies sound registration by providing helper methods for common use cases such as single sounds, variations, and custom lists.
All sound files must be placed inside:
assets/<modid>/sounds/
Supported structures:
- Flat:
sounds/my_sound.ogg - Subfolders:
sounds/music/my_song.ogg - Nested:
sounds/sfx/voices/voice_1.ogg
Variation rule:
- Use the pattern
name_#starting at 1 - Example:
sound_1.ogg, sound_2.ogg, sound_3.ogg
Usage:
@Override
protected void registerSounds(JsonObject root) {
sound(root, "vine_boom", "misc/vine_boom");
variations(root, "fire_cracking", "sfx/fire_crackings/fire_cracking.ogg", 5);
}
This provider only generates the JSON file. Missing sound files will result in silent or broken sounds in-game.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.data.DataProvider
net.minecraft.data.DataProvider.Factory<T extends net.minecraft.data.DataProvider> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final net.minecraft.data.PackOutputFields inherited from interface net.minecraft.data.DataProvider
FIXED_ORDER_FIELDS, KEY_COMPARATOR, LOGGER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRaccoonSoundProvider(net.minecraft.data.PackOutput output, String modid) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcustomPaths(com.google.gson.JsonObject root, String name, String... pathsAndFileNames) Registers a sound event with multiple variations from different places.@NotNull StringgetName()protected abstract voidregisterSounds(com.google.gson.JsonObject root) @NotNull CompletableFuture<?>run(@NotNull net.minecraft.data.CachedOutput cache) protected voidsingleSound(com.google.gson.JsonObject root, String soundName, String pathAndFileName) Registers a single sound event.protected voidvariedSound(com.google.gson.JsonObject root, String soundName, String pathAndFileName, int count) Registers a sound event with multiple numbered variations.
-
Field Details
-
output
protected final net.minecraft.data.PackOutput output -
modid
-
-
Constructor Details
-
RaccoonSoundProvider
-
-
Method Details
-
run
@NotNull public @NotNull CompletableFuture<?> run(@NotNull @NotNull net.minecraft.data.CachedOutput cache) - Specified by:
runin interfacenet.minecraft.data.DataProvider
-
registerSounds
protected abstract void registerSounds(com.google.gson.JsonObject root) -
singleSound
protected void singleSound(com.google.gson.JsonObject root, String soundName, String pathAndFileName) Registers a single sound event.The sound file must exist inside
assets/<modid>/sounds/. If it's inside a subfolder, you need to specify that subfolder as well.Example:
Generates:singleSound(root, "cool_music", "music/cool_music.ogg");"cool_music": { "subtitles": "sound.<modid>.cool_music", "sounds": [ "<modid>:music/cool_music" ] } -
variedSound
protected void variedSound(com.google.gson.JsonObject root, String soundName, String pathAndFileName, int count) Registers a sound event with multiple numbered variations.Files must follow the pattern:
name_1, name_2, name3, ...Example:
Generates:variedSound(root, "fire_crackling", "sfx/fire_cracklings/fire_crackling", 5);"fire_crackling": { "subtitles": "sound.<modid>.fire_crackling", "sounds": [ "<modid>:sfx/fire_cracklings/fire_crackling_1" "<modid>:sfx/fire_cracklings/fire_crackling_2" ... ] } -
customPaths
protected void customPaths(com.google.gson.JsonObject root, String name, String... pathsAndFileNames) Registers a sound event with multiple variations from different places.Useful when you're disorganized or your sounds come from different folders for some reason. Can be used if your sounds have variations with different names too.
Example:
customPaths(root, "weird_sound", "music/a.ogg", "music/b.ogg", "sfx/c.ogg" ); -
getName
- Specified by:
getNamein interfacenet.minecraft.data.DataProvider
-