package net.minecraft.client.sounds; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.util.RandomSource; /** * The Weighted interface represents an element with a weight in a weighted collection. * It is used to provide weighted selection and retrieval of elements. * * @param The type of the element */ @Environment(EnvType.CLIENT) public interface Weighted { /** * {@return The weight of the element} */ int getWeight(); /** * Retrieves the sound associated with the element. * The sound is obtained using the provided random source. *

* @return The sound associated with the element * * @param randomSource the random source used for sound selection */ T getSound(RandomSource randomSource); /** * Preloads the sound if required by the sound engine. * This method is called to preload the sound associated with the element into the sound engine, ensuring it is ready for playback. * * @param engine the sound engine used for sound preloading */ void preloadIfRequired(SoundEngine engine); }