.dev

Modules1 min read

Audio

OGG assets or vanilla sounds, positional, looping and faded.

audio:1Tier A · Decorate

Good for

  • Lobby music players can turn down on its own slider
  • Positional sounds from objectives
  • Custom sounds without a resource pack

Play your own OGG files or any vanilla sound, positional or not, looping and faded. Every sound counts toward the vanilla volume slider you choose (music or the matching sound category), and Teho adds a Server audio slider so players can turn your audio down without touching anything else.

Play

Java
Asset anthem = TehoApi.get().assets().load(Asset.Kind.OGG, dataFolder.resolve("anthem.ogg"));

teho.audio().play(Sound.asset("lobby-music", anthem)
        .music(true)
        .loop(true)
        .volume(0.6)
        .fadeIn(2000)
        .build());

teho.audio().play(Sound.vanilla("bell", "block.bell.use")
        .at(0.5, 70, 0.5)
        .pitch(1.2)
        .build());

teho.audio().play(Sound.vanilla("heartbeat", "entity.warden.heartbeat")
        .following(target.getUniqueId())
        .loop(true)
        .build());
MethodNotes
asset(id, Asset) / vanilla(id, soundId)Your OGG asset, up to 4 MB, or a vanilla sound id.
at(x, y, z) / following(entity)Positional, fixed or attached to an entity. Without either, it plays in the player's ears.
volume(double)1.0 is normal, up to 4.0.
pitch(double)1.0 is normal, from 0.1 to 4.0.
loop(boolean), fadeIn(ms)Looping and fade-in.
music(boolean)Counts toward the music slider instead of sound effects.

Stop

Java
teho.audio().stop(1500, "lobby-music");
teho.audio().stopAll(500);

The first argument is the fade-out in milliseconds.