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
Modifier and TypeFieldDescriptionprivate final ExistingFileHelper
private static final org.apache.logging.log4j.Logger
private final String
private final PackOutput
private final Map
<String, SoundDefinition> Fields inherited from interface net.minecraft.data.DataProvider
FIXED_ORDER_FIELDS, KEY_COMPARATOR
-
Constructor Summary
ModifierConstructorDescriptionprotected
SoundDefinitionsProvider
(PackOutput output, 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.run
(CachedOutput cache) private CompletableFuture
<?> save
(CachedOutput 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 -
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 theadd
methods. -
run
- Specified by:
run
in interfaceDataProvider
-
getName
- Specified by:
getName
in interfaceDataProvider
-
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
-
mapToJson
-