Package net.minecraft.client.sounds
Class WeighedSoundEvents
java.lang.Object
net.minecraft.client.sounds.WeighedSoundEvents
The WeighedSoundEvents class represents a collection of weighted sound events.
It implements the Weighted interface to provide weighted selection of sounds.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a sound event to the collection.getSound
(RandomSource pRandomSource) Retrieves a randomly selected sound from the sound events based on their weights.int
void
preloadIfRequired
(SoundEngine pEngine) Preloads the sound events into the sound engine if required.
-
Field Details
-
list
-
subtitle
-
-
Constructor Details
-
WeighedSoundEvents
- Parameters:
pLocation
- The resource location of the sound eventspSubtitleKey
- The key for the subtitle translation component, or null if no subtitle is provided
-
-
Method Details
-
getWeight
public int getWeight() -
getSound
Retrieves a randomly selected sound from the sound events based on their weights. The selection is performed using the provided random source. -
addSound
Adds a sound event to the collection.- Parameters:
pAccessor
- The weighted accessor for the sound event to be added
-
getSubtitle
-
preloadIfRequired
Preloads the sound events into the sound engine if required. This method is called to preload the sounds associated with the sound events into the sound engine, ensuring they are ready for playback.- Specified by:
preloadIfRequired
in interfaceWeighted<Sound>
- Parameters:
pEngine
- The sound engine used for sound preloading
-