How to Play One-Time and Looped Sounds Using TLib
TLib's sound API is meant to be called directly: you give it a sound event, a position or entity, and it plays. There is no complex builder to configure, which makes it quick to wire sounds into blocks, items, or commands.
One-time sounds
Call the play-sound helper with the world, the sound event, and the position (or the entity to attach it to). You can also pass volume and pitch values if you want variation. A common use is playing a sound when a player interacts with a block: trigger it in the interaction handler and pass the block position so the sound is positional and attenuates with distance.
Looped sounds
For looping audio, TLib lets you start a sound instance and keep a reference to it so you can stop it later. Start the loop when your condition begins (for example, a machine turning on or a player entering a zone) and store the handle. When the condition ends, call stop on that handle. If you attach the loop to an entity, it will follow the entity as it moves; if you attach it to a fixed position, it stays put.
Always stop loops when the source is removed or the world unloads, otherwise the sound can keep playing or leak. Test by walking away from the source to confirm attenuation behaves as expected.