Struct SoundPlay
#[non_exhaustive]pub struct SoundPlay {
pub identifier: String,
pub source: SoundSource,
pub volume: f32,
pub pitch: f32,
pub position: [f64; 3],
pub looping: bool,
pub delay: i32,
pub attenuation: SoundAttenuation,
pub relative: bool,
}Expand description
A sound about to play, for play_sound (SoundInstance’s own settings:
vanilla’s getIdentifier, getSource, getVolume, getPitch, getX/Y/Z,
isLooping, getDelay, getAttenuation and isRelative).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.identifier: StringThe sound event (minecraft:entity.pig.ambient).
source: SoundSourceThe mixer group it plays on.
volume: f32Its own volume, before the source’s and the master’s.
pitch: f32Its pitch, 1.0 unchanged.
position: [f64; 3]Where it plays, in blocks; meaningless when relative.
looping: boolIt restarts when it ends.
delay: i32Ticks between a looping sound’s repeats (SoundInstance.getDelay): 0 loops it
seamlessly, more plays it again that many ticks after it ends.
attenuation: SoundAttenuationHow it fades with distance.
relative: boolIt plays at the listener, wherever they move.
Implementations§
§impl SoundPlay
impl SoundPlay
pub fn ui(identifier: &str) -> SoundPlay
pub fn ui(identifier: &str) -> SoundPlay
Sound event identifier at the listener, not fading with distance, on the interface
source at volume and pitch 1 (SimpleSoundInstance.forUI).
pub fn at(
identifier: &str,
source: SoundSource,
position: [f64; 3],
) -> SoundPlay
pub fn at( identifier: &str, source: SoundSource, position: [f64; 3], ) -> SoundPlay
Sound event identifier at position on source, fading with distance, at volume
and pitch 1 (SimpleSoundInstance’s positioned constructor).
pub fn with_volume(self, volume: f32) -> SoundPlay
pub fn with_volume(self, volume: f32) -> SoundPlay
The same sound at volume.
pub fn with_pitch(self, pitch: f32) -> SoundPlay
pub fn with_pitch(self, pitch: f32) -> SoundPlay
The same sound at pitch.