Package net.kyori.adventure.sound
Interface Sound
-
- All Superinterfaces:
net.kyori.examination.Examinable
@NonExtendable public interface Sound extends net.kyori.examination.Examinable
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.Source
telling 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
- Since:
- 4.0.0
- See Also:
SoundStop
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Sound.Builder
A builder for sound instances.static interface
Sound.Emitter
An emitter of sounds.static class
Sound.Source
The sound source.static interface
Sound.Type
A sound type.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull SoundStop
asStop()
Gets theSoundStop
that will stop this specific sound.@NotNull Key
name()
Gets the name.float
pitch()
Gets the pitch.@NotNull java.util.OptionalLong
seed()
Get the seed used for playback of weighted sound effects.static @NotNull Sound.Builder
sound()
Create a new builder forSound
instances.static @NotNull Sound
sound(@NotNull java.util.function.Consumer<Sound.Builder> configurer)
Create a newSound
instance configured by the provided function.static @NotNull Sound
sound(@NotNull java.util.function.Supplier<? extends Sound.Type> type, @NotNull Sound.Source.Provider source, float volume, float pitch)
Creates a new sound.static @NotNull Sound
sound(@NotNull java.util.function.Supplier<? extends Sound.Type> type, @NotNull Sound.Source source, float volume, float pitch)
Creates a new sound.static @NotNull Sound
sound(@NotNull Key name, @NotNull Sound.Source.Provider source, float volume, float pitch)
Creates a new sound.static @NotNull Sound
sound(@NotNull Key name, @NotNull Sound.Source source, float volume, float pitch)
Creates a new sound.static @NotNull Sound.Builder
sound(@NotNull Sound existing)
Create a new builder forSound
instances.static @NotNull Sound
sound(@NotNull Sound.Type type, @NotNull Sound.Source.Provider source, float volume, float pitch)
Creates a new sound.static @NotNull Sound
sound(@NotNull Sound.Type type, @NotNull Sound.Source source, float volume, float pitch)
Creates a new sound.@NotNull Sound.Source
source()
Gets the source.float
volume()
Gets the volume.
-
-
-
Method Detail
-
sound
@NotNull static @NotNull Sound.Builder sound()
Create a new builder forSound
instances.- Returns:
- a new builder
- Since:
- 4.12.0
-
sound
@NotNull static @NotNull Sound.Builder sound(@NotNull @NotNull Sound existing)
Create a new builder forSound
instances.- Parameters:
existing
- an existing sound to populate the builder with- Returns:
- a new builder
- Since:
- 4.12.0
-
sound
@NotNull static @NotNull Sound sound(@NotNull @NotNull java.util.function.Consumer<Sound.Builder> configurer)
Create a newSound
instance configured by the provided function.- Parameters:
configurer
- a function that configures a builder- Returns:
- a new builder
- Since:
- 4.12.0
-
sound
@NotNull static @NotNull Sound sound(@NotNull @NotNull Key name, @NotNull @NotNull Sound.Source source, float volume, float pitch)
Creates a new sound.- Parameters:
name
- the namesource
- the sourcevolume
- the volumepitch
- the pitch- Returns:
- the sound
- Since:
- 4.0.0
-
sound
@NotNull static @NotNull Sound sound(@NotNull @NotNull Sound.Type type, @NotNull @NotNull 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
@NotNull static @NotNull Sound sound(@NotNull @NotNull java.util.function.Supplier<? extends Sound.Type> type, @NotNull @NotNull 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
@NotNull static @NotNull Sound sound(@NotNull @NotNull Key name, @NotNull Sound.Source.Provider source, float volume, float pitch)
Creates a new sound.- Parameters:
name
- the namesource
- the sourcevolume
- the volumepitch
- the pitch- Returns:
- the sound
- Since:
- 4.8.0
-
sound
@NotNull static @NotNull Sound sound(@NotNull @NotNull Sound.Type type, @NotNull 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
-
sound
@NotNull static @NotNull Sound sound(@NotNull @NotNull java.util.function.Supplier<? extends Sound.Type> type, @NotNull 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
@NotNull @NotNull Key name()
Gets the name.- Returns:
- the name
- Since:
- 4.0.0
-
source
@NotNull @NotNull Sound.Source source()
Gets the source.- Returns:
- the source
- Since:
- 4.0.0
-
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
@NotNull @NotNull java.util.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
-
-