Class AutoSoundProvider

java.lang.Object
net.kamkeyke.raccooncore.datagen.RaccoonSoundProvider
net.kamkeyke.raccooncore.datagen.AutoSoundProvider
All Implemented Interfaces:
net.minecraft.data.DataProvider
Direct Known Subclasses:
ExampleAutoModSoundProvider

public abstract class AutoSoundProvider extends RaccoonSoundProvider
Automatic data provider for generating 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:

  1. Register this provider during the GatherDataEvent.
  2. Run your development environment's runData task (such as Gradle's runData, 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.

  • Constructor Details

    • AutoSoundProvider

      protected AutoSoundProvider(net.minecraft.data.PackOutput output, String modid)
  • Method Details