Interface Sound
public sealed interface Sound
Represents an in-game sound which can be played to the client.
A sound consists of:
- key/type
- the resource location of this sound (e.g minecraft:ambient.cave or my_plugin:custom_sound
- source
- a
Sound.Sourcetelling the game where the sound is coming from - volume
- a number in the range [0,∞) representing how loud the sound should be played. Increasing volume does not actually play the sound louder, but increases the radius of where it can be heard
- pitch
- a number in the range [0,2] representing which pitch the sound should be played at
There are some bugs that are of note when using sounds:
- Since:
- 4.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA builder for sound instances.static interfaceAn emitter of sounds.static enumThe sound source.static interfaceA sound type. -
Method Summary
Modifier and TypeMethodDescriptionasStop()Gets theSoundStopthat will stop this specific sound.name()Gets the name.floatpitch()Gets the pitch.seed()Get the seed used for playback of weighted sound effects.static Sound.Buildersound()Create a new builder forSoundinstances.static Soundsound(Consumer<Sound.Builder> configurer) Create a newSoundinstance configured by the provided function.static Soundsound(Supplier<? extends Sound.Type> type, Sound.Source.Provider source, float volume, float pitch) Creates a new sound.static Soundsound(Supplier<? extends Sound.Type> type, Sound.Source source, float volume, float pitch) Creates a new sound.static Soundsound(Key name, Sound.Source.Provider source, float volume, float pitch) Creates a new sound.static Soundsound(Key name, Sound.Source source, float volume, float pitch) Creates a new sound.static Sound.BuilderCreate a new builder forSoundinstances.static Soundsound(Sound.Type type, Sound.Source.Provider source, float volume, float pitch) Creates a new sound.static Soundsound(Sound.Type type, Sound.Source source, float volume, float pitch) Creates a new sound.source()Gets the source.floatvolume()Gets the volume.
-
Method Details
-
sound
Create a new builder forSoundinstances.- Returns:
- a new builder
- Since:
- 4.12.0
-
sound
Create a new builder forSoundinstances.- Parameters:
existing- an existing sound to populate the builder with- Returns:
- a new builder
- Since:
- 4.12.0
-
sound
Create a newSoundinstance configured by the provided function.- Parameters:
configurer- a function that configures a builder- Returns:
- a new builder
- Since:
- 4.12.0
-
sound
Creates a new sound.- Parameters:
name- the namesource- the sourcevolume- the volumepitch- the pitch- Returns:
- the sound
- Since:
- 4.0.0
-
sound
Creates a new sound.- Parameters:
type- the typesource- the sourcevolume- the volumepitch- the pitch- Returns:
- the sound
- Since:
- 4.0.0
-
sound
static Sound sound(Supplier<? extends Sound.Type> type, Sound.Source source, float volume, float pitch) Creates a new sound.- Parameters:
type- the typesource- the sourcevolume- the volumepitch- the pitch- Returns:
- the sound
- Since:
- 4.0.0
-
sound
Creates a new sound.- Parameters:
name- the namesource- the sourcevolume- the volumepitch- the pitch- Returns:
- the sound
- Since:
- 4.8.0
-
sound
Creates a new sound.- Parameters:
type- the typesource- the sourcevolume- the volumepitch- the pitch- Returns:
- the sound
- Since:
- 4.8.0
-
sound
static Sound sound(Supplier<? extends Sound.Type> type, Sound.Source.Provider source, float volume, float pitch) Creates a new sound.- Parameters:
type- the typesource- the sourcevolume- the volumepitch- the pitch- Returns:
- the sound
- Since:
- 4.8.0
-
name
-
source
-
volume
float volume()Gets the volume.- Returns:
- the volume
- Since:
- 4.0.0
-
pitch
float pitch()Gets the pitch.- Returns:
- the pitch
- Since:
- 4.0.0
-
seed
OptionalLong seed()Get the seed used for playback of weighted sound effects.When the seed is not provided, the seed of the receiver's world will be used instead.
- Returns:
- the seed to use
- Since:
- 4.12.0
-
asStop
-