Package net.minecraftforge.common.data
Class SoundDefinitionsProvider
java.lang.Object
net.minecraftforge.common.data.SoundDefinitionsProvider
- All Implemented Interfaces:
IDataProvider
- Direct Known Subclasses:
DataGeneratorTest.SoundDefinitions
Data provider for the
sounds.json
file, which identifies sound definitions
for the various sound events in Minecraft.-
Field Summary
Modifier and TypeFieldDescriptionprivate final DataGenerator
private static final com.google.gson.Gson
private final ExistingFileHelper
private static final org.apache.logging.log4j.Logger
private final String
private final Map<String,
SoundDefinition> Fields inherited from interface net.minecraft.data.IDataProvider
SHA1
-
Constructor Summary
ModifierConstructorDescriptionprotected
SoundDefinitionsProvider
(DataGenerator generator, String modId, ExistingFileHelper helper) Creates a new instance of this data provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
add
(String soundEvent, SoundDefinition definition) Adds theSoundEvent
with the specified name along with itsSoundDefinition
to the list.protected void
add
(Supplier<SoundEvent> soundEvent, SoundDefinition definition) Adds the entry name associated with the suppliedSoundEvent
with the givenSoundDefinition
to the list.protected void
add
(ResourceLocation soundEvent, SoundDefinition definition) protected void
add
(SoundEvent soundEvent, SoundDefinition definition) Adds the entry name associated with the givenSoundEvent
with theSoundDefinition
to the list.private void
addSounds
(String soundEvent, SoundDefinition definition) protected static SoundDefinition
Creates a newSoundDefinition
, which will host a set ofSoundDefinition.Sound
s and the necessary parameters.getName()
private com.google.gson.JsonObject
mapToJson
(Map<String, SoundDefinition> map) abstract void
Registers the sound definitions that should be generated via one of theadd
methods.void
run
(DirectoryCache cache) private void
save
(DirectoryCache cache, Path targetFile) protected static SoundDefinition.Sound
Creates a new sound with the given name andSoundDefinition.SoundType.SOUND
as sound type.protected static SoundDefinition.Sound
sound
(String name, SoundDefinition.SoundType type) Creates a new sound with the given name and type.protected static SoundDefinition.Sound
sound
(ResourceLocation name) Creates a new sound with the given name andSoundDefinition.SoundType.SOUND
as sound type.protected static SoundDefinition.Sound
sound
(ResourceLocation name, SoundDefinition.SoundType type) Creates a new sound with the given name and type.private void
validate()
private boolean
validate
(String name, SoundDefinition def) private boolean
validate
(String name, SoundDefinition.Sound sound) private boolean
validateEvent
(String soundName, ResourceLocation name) private boolean
validateSound
(String soundName, ResourceLocation name)
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
GSON
private static final com.google.gson.Gson GSON -
generator
-
modId
-
helper
-
sounds
-
-
Constructor Details
-
SoundDefinitionsProvider
protected SoundDefinitionsProvider(DataGenerator generator, String modId, ExistingFileHelper helper) Creates a new instance of this data provider.- Parameters:
generator
- The data generator instance provided by the event you are initializing this provider in.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 theadd
methods. -
run
- Specified by:
run
in interfaceIDataProvider
- Throws:
IOException
-
getName
- Specified by:
getName
in interfaceIDataProvider
-
definition
Creates a newSoundDefinition
, which will host a set ofSoundDefinition.Sound
s 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.SOUND
as 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.SOUND
as sound type.- Parameters:
name
- The name of the sound to create.
-
add
Adds the entry name associated with the suppliedSoundEvent
with the givenSoundDefinition
to the list.This method should be preferred when dealing with a
RegistryObject
orRegistryDelegate
.- Parameters:
soundEvent
- ASupplier
for the givenSoundEvent
.definition
- ASoundDefinition
that defines the given sound.
-
add
Adds the entry name associated with the givenSoundEvent
with theSoundDefinition
to the list.This method should be preferred when a
SoundEvent
is already available in the method context. If you already have aSupplier
for it, refer toadd(Supplier, SoundDefinition)
.- Parameters:
soundEvent
- ASoundEvent
.definition
- TheSoundDefinition
that defines the given event.
-
add
- Parameters:
soundEvent
- TheResourceLocation
that identifies the event.definition
- TheSoundDefinition
that defines the given event.
-
add
Adds theSoundEvent
with the specified name along with itsSoundDefinition
to 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
- TheSoundDefinition
that defines the given event.
-
addSounds
-
validate
private void validate() -
validate
-
validate
-
validateSound
-
validateEvent
-
save
- Throws:
IOException
-
mapToJson
-