Package net.minecraftforge.event
Class PlayLevelSoundEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.PlayLevelSoundEvent
- Direct Known Subclasses:
- PlayLevelSoundEvent.AtEntity,- PlayLevelSoundEvent.AtPosition
public class PlayLevelSoundEvent
extends net.minecraftforge.eventbus.api.Event
PlayLevelSoundEvent is fired when a sound is played on a 
Level.
 This event is fired from Level.playSound(net.minecraft.world.entity.Entity, net.minecraft.core.BlockPos, net.minecraft.sounds.SoundEvent, net.minecraft.sounds.SoundSource, float, float), Level.playSeededSound(net.minecraft.world.entity.player.Player, double, double, double, net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent>, net.minecraft.sounds.SoundSource, float, float, long), and LocalPlayer.playSound(net.minecraft.sounds.SoundEvent, float, float).
 
 getLevel() contains the level the sound is being played in.
 getSound() contains the sound event to be played.
 getOriginalVolume() contains the original volume for the sound to be played at.
 getOriginalPitch() contains the original pitch for the sound to be played at.
 getNewVolume() contains the volume the sound will be played at.
 getNewPitch() contains the pitch the sound will be played at.
 
 This event is cancelable.
 If this event is canceled, the sound is not played.
 
This event does not have a result.
 This event is fired on the MinecraftForge.EVENT_BUS.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic classPlayLevelSoundEvent.AtPosition is fired when a sound is played on theLevelat a specific position.Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Eventnet.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final Levelprivate floatprivate floatprivate final floatprivate final floatprivate Holder<SoundEvent>private SoundSource
- 
Constructor SummaryConstructorsConstructorDescriptionPlayLevelSoundEvent(@NotNull Level level, @NotNull Holder<SoundEvent> sound, @NotNull SoundSource source, float volume, float pitch) 
- 
Method SummaryModifier and TypeMethodDescription@NotNull LevelgetLevel()Returns the level the sound is being played in.floatReturns the pitch the sound will be played at.floatReturns the volume the sound will be played at.floatReturns the original pitch for the sound to be played at.floatReturns the original volume for the sound to be played at.@Nullable Holder<SoundEvent>getSound()Returns the sound event to be played.@NotNull SoundSourceReturns the sound source.voidsetNewPitch(float newPitch) Sets the pitch the sound will be played at.voidsetNewVolume(float newVolume) Sets the volume the sound will be played at.voidsetSound(@Nullable Holder<SoundEvent> sound) Sets the sound event to be played.voidsetSource(@NotNull SoundSource source) Sets the sound source.Methods inherited from class net.minecraftforge.eventbus.api.EventgetListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
- 
Field Details- 
level
- 
originalVolumeprivate final float originalVolume
- 
originalPitchprivate final float originalPitch
- 
sound
- 
source
- 
newVolumeprivate float newVolume
- 
newPitchprivate float newPitch
 
- 
- 
Constructor Details- 
PlayLevelSoundEventpublic PlayLevelSoundEvent(@NotNull @NotNull Level level, @NotNull @NotNull Holder<SoundEvent> sound, @NotNull @NotNull SoundSource source, float volume, float pitch) 
 
- 
- 
Method Details- 
getLevelReturns the level the sound is being played in.- Returns:
- the level the sound is being played in
 
- 
getSoundReturns the sound event to be played.- Returns:
- the sound event to be played
 
- 
setSoundSets the sound event to be played.
- 
getSourceReturns the sound source.- Returns:
- the sound source
 
- 
setSourceSets the sound source.
- 
getOriginalVolumepublic float getOriginalVolume()Returns the original volume for the sound to be played at.- Returns:
- the original volume for the sound to be played at
 
- 
getOriginalPitchpublic float getOriginalPitch()Returns the original pitch for the sound to be played at.- Returns:
- the original pitch for the sound to be played at
 
- 
getNewVolumepublic float getNewVolume()Returns the volume the sound will be played at.- Returns:
- the volume the sound will be played at
 
- 
setNewVolumepublic void setNewVolume(float newVolume) Sets the volume the sound will be played at.
- 
getNewPitchpublic float getNewPitch()Returns the pitch the sound will be played at.- Returns:
- the pitch the sound will be played at
 
- 
setNewPitchpublic void setNewPitch(float newPitch) Sets the pitch the sound will be played at.
 
-