Class PlaySoundEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.client.event.sound.SoundEvent
net.neoforged.neoforge.client.event.sound.PlaySoundEvent
Fired when a sound is about to be played by the sound engine. This fires before the sound is played and before any
 checks on the sound (such as a zeroed volume, an empty 
Sound, and
 others). This can be used to change or prevent (by passing null) a sound from being played through
 setSound(SoundInstance)).
 This event is not cancellable, and does not have a result.
This event is fired on the main Forge event bus, only on the logical client.
- See Also:
 
- 
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.client.event.sound.SoundEvent
SoundEvent.SoundSourceEventNested classes/interfaces inherited from class net.neoforged.bus.api.Event
net.neoforged.bus.api.Event.HasResult, net.neoforged.bus.api.Event.Result - 
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate final SoundInstanceprivate @Nullable SoundInstance - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptiongetName()Returns the name of the original sound.Returns the original sound that was to be played.@Nullable SoundInstancegetSound()Returns the sound to be played, ornullif no sound will be played.voidsetSound(@Nullable SoundInstance newSound) Sets the sound to be played, which may benullto prevent any sound from being played.Methods inherited from class net.neoforged.neoforge.client.event.sound.SoundEvent
getEngineMethods inherited from class net.neoforged.bus.api.Event
getResult, hasResult, setResult 
- 
Field Details
- 
name
 - 
originalSound
 - 
sound
 
 - 
 - 
Constructor Details
- 
PlaySoundEvent
 
 - 
 - 
Method Details
- 
getName
Returns the name of the original sound. This is equivalent to the path of the location of the original sound.- Returns:
 - the name of the original sound
 
 - 
getOriginalSound
Returns the original sound that was to be played.- Returns:
 - the original sound that was to be played
 
 - 
getSound
Returns the sound to be played, ornullif no sound will be played.- Returns:
 - the sound to be played, or 
nullif no sound will be played 
 - 
setSound
Sets the sound to be played, which may benullto prevent any sound from being played.- Parameters:
 newSound- the new sound to be played, ornullfor no sound
 
 -