Class PlaySoundEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.client.event.sound.SoundEvent
net.minecraftforge.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.minecraftforge.client.event.sound.SoundEvent
SoundEvent.SoundSourceEvent
Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
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.minecraftforge.client.event.sound.SoundEvent
getEngine
Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, 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, 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
-