Package net.minecraftforge.common.data
Class SoundDefinitionsProvider
java.lang.Object
net.minecraftforge.common.data.SoundDefinitionsProvider
- All Implemented Interfaces:
DataProvider
- Direct Known Subclasses:
VanillaSoundDefinitionsProvider
Data provider for the
sounds.json file, which identifies sound definitions
for the various sound events in Minecraft.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.data.DataProvider
DataProvider.Factory<T extends DataProvider> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ExistingFileHelperprivate static final org.apache.logging.log4j.Loggerprivate final Stringprivate final PackOutputprivate final Map<String, SoundDefinition> Fields inherited from interface net.minecraft.data.DataProvider
FIXED_ORDER_FIELDS, KEY_COMPARATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSoundDefinitionsProvider(PackOutput output, String modId, ExistingFileHelper helper) Creates a new instance of this data provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidadd(String soundEvent, SoundDefinition definition) Adds theSoundEventwith the specified name along with itsSoundDefinitionto the list.protected voidadd(Supplier<SoundEvent> soundEvent, SoundDefinition definition) Adds the entry name associated with the suppliedSoundEventwith the givenSoundDefinitionto the list.protected voidadd(ResourceLocation soundEvent, SoundDefinition definition) protected voidadd(SoundEvent soundEvent, SoundDefinition definition) Adds the entry name associated with the givenSoundEventwith theSoundDefinitionto the list.private voidaddSounds(String soundEvent, SoundDefinition definition) protected static SoundDefinitionCreates a newSoundDefinition, which will host a set ofSoundDefinition.Sounds and the necessary parameters.getName()private com.google.gson.JsonObjectmapToJson(Map<String, SoundDefinition> map) abstract voidRegisters the sound definitions that should be generated via one of theaddmethods.run(CachedOutput cache) private CompletableFuture<?> save(CachedOutput cache, Path targetFile) protected static SoundDefinition.SoundCreates a new sound with the given name andSoundDefinition.SoundType.SOUNDas sound type.protected static SoundDefinition.Soundsound(String name, SoundDefinition.SoundType type) Creates a new sound with the given name and type.protected static SoundDefinition.Soundsound(ResourceLocation name) Creates a new sound with the given name andSoundDefinition.SoundType.SOUNDas sound type.protected static SoundDefinition.Soundsound(ResourceLocation name, SoundDefinition.SoundType type) Creates a new sound with the given name and type.private voidvalidate()private booleanvalidate(String name, SoundDefinition def) private booleanvalidate(String name, SoundDefinition.Sound sound) private booleanvalidateEvent(String soundName, ResourceLocation name) private booleanvalidateSound(String soundName, ResourceLocation name)
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
output
-
modId
-
helper
-
sounds
-
-
Constructor Details
-
SoundDefinitionsProvider
Creates a new instance of this data provider.- Parameters:
output- The PackOutput instance provided by the data generator.modId- The mod ID of the current mod.helper- The existing file helper provided by the event you are initializing this provider in.
-
-
Method Details
-
registerSounds
public abstract void registerSounds()Registers the sound definitions that should be generated via one of theaddmethods. -
run
- Specified by:
runin interfaceDataProvider
-
getName
- Specified by:
getNamein interfaceDataProvider
-
definition
Creates a newSoundDefinition, which will host a set ofSoundDefinition.Sounds and the necessary parameters. -
sound
Creates a new sound with the given name and type.- Parameters:
name- The name of the sound to create.type- The type of sound to create.
-
sound
Creates a new sound with the given name andSoundDefinition.SoundType.SOUNDas sound type.- Parameters:
name- The name of the sound to create.
-
sound
Creates a new sound with the given name and type.- Parameters:
name- The name of the sound to create.type- The type of sound to create.
-
sound
Creates a new sound with the given name andSoundDefinition.SoundType.SOUNDas sound type.- Parameters:
name- The name of the sound to create.
-
add
Adds the entry name associated with the suppliedSoundEventwith the givenSoundDefinitionto the list.This method should be preferred when dealing with a
RegistryObjectorRegistryDelegate.- Parameters:
soundEvent- ASupplierfor the givenSoundEvent.definition- ASoundDefinitionthat defines the given sound.
-
add
Adds the entry name associated with the givenSoundEventwith theSoundDefinitionto the list.This method should be preferred when a
SoundEventis already available in the method context. If you already have aSupplierfor it, refer toadd(Supplier, SoundDefinition).- Parameters:
soundEvent- ASoundEvent.definition- TheSoundDefinitionthat defines the given event.
-
add
- Parameters:
soundEvent- TheResourceLocationthat identifies the event.definition- TheSoundDefinitionthat defines the given event.
-
add
Adds theSoundEventwith the specified name along with itsSoundDefinitionto the list.The given sound event must NOT contain the namespace the name is a part of, since the sound definition specification doesn't allow sounds to be defined outside the namespace they're in. For this reason, any namespace will automatically be stripped from the name.
- Parameters:
soundEvent- The name of theSoundEvent.definition- TheSoundDefinitionthat defines the given event.
-
addSounds
-
validate
private void validate() -
validate
-
validate
-
validateSound
-
validateEvent
-
save
-
mapToJson
-