Sounds & Environment API
PotatoMC offers rich audio and environmental controls for manipulating sound effects, weather conditions, lightning bolts, and world block heights with zero overhead.
1. Playing Sound Effects
Play vanilla sounds targeting either individual players or broadcast across an area in a world:
use potato_api::sound::{Sound, SoundCategory};
// 1. Play sound to a specific player
player.play_sound(Sound::ENTITY_PLAYER_LEVELUP, 1.0, 1.0);
// 2. Play sound with an explicit SoundCategory
player.play_sound_category(Sound::BLOCK_NOTE_BLOCK_PLING, SoundCategory::Blocks, 1.0, 1.2);
// 3. Stop playing sounds
player.stop_sound(Some("minecraft:music.game"));
player.stop_sound(None); // Stop all active sounds
// 4. Play sound in the world at a position
world.play_sound(&location, Sound::ENTITY_GENERIC_EXPLODE, 1.0, 0.8);Built-in Sound Constants
potato_api::sound::Sound includes typed constants for frequently used vanilla cues:
Sound::ENTITY_PLAYER_LEVELUPSound::ENTITY_EXPERIENCE_ORB_PICKUPSound::BLOCK_NOTE_BLOCK_PLINGSound::BLOCK_CHEST_OPEN/Sound::BLOCK_CHEST_CLOSESound::ENTITY_GENERIC_EXPLODESound::ENTITY_LIGHTNING_BOLT_THUNDERSound::UI_BUTTON_CLICKSound::UI_TOAST_CHALLENGE_COMPLETE
2. Lightning Strikes
// Real lightning strike: creates fire, thunder sound, and deals damage
world.strike_lightning(&location);
// Cosmetic lightning effect: visual bolt and sound with NO fire or damage
world.strike_lightning_effect(&location);3. Weather & World Environment Control
// Toggle storm / rain
world.set_storm(true);
println!("Is raining: {}", world.is_raining());
// Toggle thundering
world.set_thundering(true);
println!("Is thundering: {}", world.is_thundering());
// Query highest solid block Y coordinate at given X/Z
let highest_y = world.get_highest_block_y(100, -250);