Skip to main content

EffectsClientHost

Trait EffectsClientHost 

pub trait EffectsClientHost {
    // Provided methods
    fn muffle_sounds(
        &mut self,
        amount: f32,
        lowpass: f32,
        ticks: u32,
        exempt: &[&str],
    ) -> bool { ... }
    fn flame_particle(&mut self, at: [f64; 3], soul: bool) { ... }
    fn play_local_sound(
        &self,
        sound: &SoundPlay,
        after: u32,
    ) -> Option<SoundRef> { ... }
    fn particle_count(&self) -> u32 { ... }
    fn clear_particles(&self) -> bool { ... }
    fn add_particle(
        &mut self,
        options: &ParticleOptions,
        at: [f64; 3],
        velocity: [f64; 3],
    ) -> bool { ... }
    fn sound_events(&self) -> Vec<Identifier> { ... }
    fn audio_devices(&self) -> Vec<String> { ... }
    fn audio_device(&self) -> String { ... }
}
Expand description

The client host’s methods of the effects area, implemented by the game and reached through crate::ClientHost.

Provided Methods§

fn muffle_sounds( &mut self, amount: f32, lowpass: f32, ticks: u32, exempt: &[&str], ) -> bool

Muffles the game’s sounds for a while, as ears ringing after a close blast hear them: amount (0 to 1) of every sound’s volume is taken away and lowpass (0 to 1) dulls it, from untouched to a 300 Hz low-pass. Both start in full and fade back in a straight line over ticks client ticks, held while the game is paused. The sound events in exempt (mymod:ear.ringing) play clearly through it, those already playing too, so the mod’s own ringing stays sharp. Everything else is muffled, music and the interface’s clicks included. A new call replaces the muffle in place; ticks 0 ends it at once. Nothing changes while no mod calls it. False, with nothing changed, on a server, for an amount or strength outside 0 to 1, or for an exempt event that isn’t namespace:path or more than 64 of them. API @API:muffle_sounds@.

fn flame_particle(&mut self, at: [f64; 3], soul: bool)

Side: client. A small local vanilla particle; caller should rate-limit emission.

fn play_local_sound(&self, sound: &SoundPlay, after: u32) -> Option<SoundRef>

Side: client. Plays sound for this player only (SoundPlay’s event: minecraft:ui.button.click, or a mod’s own from its assets/<id>/sounds.json): nothing is sent to the server, and other players don’t hear it. It takes &self, so a screen, key or mouse hook can play one: the sound is queued and starts at the next audio update (once a client tick), after ticks counted from then (0 to 1200, a minute; SoundEngine.playDelayed). SoundPlay::ui plays it at the listener as an interface sound (SimpleSoundInstance.forUI); SoundPlay::at at a position in the client’s level, fading with distance (volume past 1 carries farther, 16 blocks times the volume), as thunder heard after the flash or a blast heard when its shock wave arrives. Its SoundRef follows and controls this play: state, stop and fade. None, with nothing played, on a server or for a value out of range; an event the resources don’t have plays nothing, as vanilla’s, and its handle reads Stopped once the update has tried it.

fn particle_count(&self) -> u32

Side: client. The particles alive in the client’s level (ParticleEngine.countParticles): 0 once a clear is asked, and on a server.

fn clear_particles(&self) -> bool

Side: client. ParticleEngine.clearParticles: every particle and emitter goes before the next frame is drawn or the next particle tick runs, whichever comes first. It takes &self, so a screen or render hook can ask, as with native_play_local_sound. False on a server.

fn add_particle( &mut self, options: &ParticleOptions, at: [f64; 3], velocity: [f64; 3], ) -> bool

Side: client. ClientLevel.addParticle: submits one local particle through the ordinary provider, camera-distance, setting and population limits. False without a loaded client world or for non-finite input. True means submitted, not necessarily visible.

fn sound_events(&self) -> Vec<Identifier>

Every sound event the client’s resources have (SoundManager.getAvailableSounds).

fn audio_devices(&self) -> Vec<String>

Side: client. The output devices sound can play on (SoundEngine.getAvailableSoundDevices).

fn audio_device(&self) -> String

Side: client. The output device the options ask for (Options.soundDevice).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§