Class AutoSoundProvider
- All Implemented Interfaces:
net.minecraft.data.DataProvider
- Direct Known Subclasses:
ExampleAutoModSoundProvider
sounds.json from a list of SoundEntry.
To see an example of usage head to ExampleAutoModSoundProvider.
Instead of manually calling RaccoonSoundProvider.singleSound(JsonObject, String, String),
RaccoonSoundProvider.variedSound(JsonObject, String, String, int) or
RaccoonSoundProvider.customPaths(JsonObject, String, String...),
this provider automatically generates every sound event from the list returned by
getEntries().
Each SoundEntry is analyzed and the appropriate registration method is selected:
- If
customPathsAndNames()is present,customPaths(...)is used. - If
variations() > 0,variedSound(...)is used. - Otherwise,
singleSound(...)is used.
In most cases, getEntries() should simply return the list of
SoundEntry maintained by your mod's sound registry.
This allows your registry to become the single source of truth for both
SoundEvent registration and sounds.json
generation, eliminating duplicated definitions.
To generate the file:
- Register this provider during the
GatherDataEvent. - Run your development environment's
runDatatask (such as Gradle'srunData, depending on your setup).
This provider only generates the JSON file.
All referenced sound files must still exist under
assets/<modid>/sounds/.
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
Fields inherited from class net.kamkeyke.raccooncore.datagen.RaccoonSoundProvider
modid, outputFields inherited from interface net.minecraft.data.DataProvider
FIXED_ORDER_FIELDS, KEY_COMPARATOR, LOGGER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAutoSoundProvider(net.minecraft.data.PackOutput output, String modid) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract List<SoundEntry>protected voidregisterSounds(com.google.gson.JsonObject root) Methods inherited from class net.kamkeyke.raccooncore.datagen.RaccoonSoundProvider
customPaths, getName, run, singleSound, variedSound
-
Constructor Details
-
AutoSoundProvider
-
-
Method Details
-
getEntries
-
registerSounds
protected void registerSounds(com.google.gson.JsonObject root) - Specified by:
registerSoundsin classRaccoonSoundProvider
-