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
, and does not
invalid reference
cancellable
.invalid reference
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.SoundSourceEvent
-
Field Summary
Modifier and TypeFieldDescriptionprivate final String
private final SoundInstance
private @Nullable SoundInstance
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetName()
Returns the name of the original sound.Returns the original sound that was to be played.@Nullable SoundInstance
getSound()
Returns the sound to be played, ornull
if no sound will be played.void
setSound
(@Nullable SoundInstance newSound) Sets the sound to be played, which may benull
to prevent any sound from being played.Methods inherited from class net.neoforged.neoforge.client.event.sound.SoundEvent
getEngine
-
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, ornull
if no sound will be played.- Returns:
- the sound to be played, or
null
if no sound will be played
-
setSound
Sets the sound to be played, which may benull
to prevent any sound from being played.- Parameters:
newSound
- the new sound to be played, ornull
for no sound
-