Package com.minecolonies.api.util
Class SoundUtils
java.lang.Object
com.minecolonies.api.util.SoundUtils
Utilities for playing sounds.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraftforge.event.level.NoteBlockEvent.Note[]A much less chaotic scale (D major pentatonic) for random pitchesstatic final floatStandard pitch value.static final doubleVolume to play at. -
Method Summary
Modifier and TypeMethodDescriptionstatic doublegetRandomPentatonic(net.minecraft.util.RandomSource random) Generates a random tone from the D major pentatonic scalestatic doublegetRandomPitch(net.minecraft.util.RandomSource random) Get a random pitch for a sound.static voidplayErrorSound(@NotNull net.minecraft.world.entity.player.Player player, @NotNull net.minecraft.core.BlockPos position) Play an error sound.static voidplayRandomSound(@NotNull net.minecraft.world.level.Level worldIn, @NotNull net.minecraft.core.BlockPos pos, @NotNull ICitizenData citizen) Play a random sound at the citizen.static voidplaySoundAtCitizen(@NotNull net.minecraft.world.level.Level worldIn, @NotNull net.minecraft.core.BlockPos position, @NotNull net.minecraft.sounds.SoundEvent event) Play a sound at a certain position.static voidplaySoundAtCitizenWith(@NotNull net.minecraft.world.level.Level worldIn, @NotNull net.minecraft.core.BlockPos position, @Nullable EventType type, @Nullable ICivilianData citizenData) Plays a sound with a certain chance at a certain position.static voidplaySoundAtCitizenWith(@NotNull net.minecraft.world.level.Level worldIn, @NotNull net.minecraft.core.BlockPos position, @Nullable EventType type, @Nullable ICivilianData citizenData, double chance) Plays a sound with a certain chance at a certain position.static voidplaySoundAtCitizenWith(@NotNull net.minecraft.world.level.Level worldIn, @NotNull net.minecraft.core.BlockPos position, @Nullable EventType type, @Nullable ICivilianData citizenData, double chance, double volume) Plays a sound with a certain chance at a certain position.static voidplaySoundForPlayer(net.minecraft.server.level.ServerPlayer playerEntity, net.minecraft.sounds.SoundEvent sound, float volume, float pitch) Plays a sound for the given player, but not for surrounding entitiesstatic voidplaySuccessSound(@NotNull net.minecraft.world.entity.player.Player player, @NotNull net.minecraft.core.BlockPos position) Play a success sound.
-
Field Details
-
PITCH
public static final float PITCHStandard pitch value.- See Also:
-
VOLUME
public static final double VOLUMEVolume to play at.- See Also:
-
PENTATONIC
public static final net.minecraftforge.event.level.NoteBlockEvent.Note[] PENTATONICA much less chaotic scale (D major pentatonic) for random pitches
-
-
Method Details
-
playRandomSound
public static void playRandomSound(@NotNull @NotNull net.minecraft.world.level.Level worldIn, @NotNull @NotNull net.minecraft.core.BlockPos pos, @NotNull @NotNull ICitizenData citizen) Play a random sound at the citizen.- Parameters:
worldIn- the world to play it in.pos- the pos to play it at.citizen- the citizen to play it for.
-
playSoundAtCitizen
public static void playSoundAtCitizen(@NotNull @NotNull net.minecraft.world.level.Level worldIn, @NotNull @NotNull net.minecraft.core.BlockPos position, @NotNull @NotNull net.minecraft.sounds.SoundEvent event) Play a sound at a certain position.- Parameters:
worldIn- the world to play the sound in.position- the position to play the sound at.event- sound to play.
-
playSuccessSound
public static void playSuccessSound(@NotNull @NotNull net.minecraft.world.entity.player.Player player, @NotNull @NotNull net.minecraft.core.BlockPos position) Play a success sound.- Parameters:
player- the player to play it for.position- the position it is played at.
-
playErrorSound
public static void playErrorSound(@NotNull @NotNull net.minecraft.world.entity.player.Player player, @NotNull @NotNull net.minecraft.core.BlockPos position) Play an error sound.- Parameters:
player- the player to play it for.position- the position it is played at.
-
playSoundAtCitizenWith
public static void playSoundAtCitizenWith(@NotNull @NotNull net.minecraft.world.level.Level worldIn, @NotNull @NotNull net.minecraft.core.BlockPos position, @Nullable @Nullable EventType type, @Nullable @Nullable ICivilianData citizenData) Plays a sound with a certain chance at a certain position.- Parameters:
worldIn- the world to play the sound in.position- position to play the sound at.type- sound to play.citizenData- the citizen.
-
playSoundAtCitizenWith
public static void playSoundAtCitizenWith(@NotNull @NotNull net.minecraft.world.level.Level worldIn, @NotNull @NotNull net.minecraft.core.BlockPos position, @Nullable @Nullable EventType type, @Nullable @Nullable ICivilianData citizenData, double chance, double volume) Plays a sound with a certain chance at a certain position.- Parameters:
worldIn- the world to play the sound in.position- position to play the sound at.type- sound to play.citizenData- the citizen.
-
playSoundAtCitizenWith
public static void playSoundAtCitizenWith(@NotNull @NotNull net.minecraft.world.level.Level worldIn, @NotNull @NotNull net.minecraft.core.BlockPos position, @Nullable @Nullable EventType type, @Nullable @Nullable ICivilianData citizenData, double chance) Plays a sound with a certain chance at a certain position.- Parameters:
worldIn- the world to play the sound in.position- position to play the sound at.type- sound to play.citizenData- the citizen.
-
getRandomPitch
public static double getRandomPitch(net.minecraft.util.RandomSource random) Get a random pitch for a sound.- Parameters:
random- the random method.- Returns:
- a random double for the pitch.
-
getRandomPentatonic
public static double getRandomPentatonic(net.minecraft.util.RandomSource random) Generates a random tone from the D major pentatonic scale- Parameters:
random- the RNG instance- Returns:
- a number representing the pitch to the sound engine
-
playSoundForPlayer
public static void playSoundForPlayer(net.minecraft.server.level.ServerPlayer playerEntity, net.minecraft.sounds.SoundEvent sound, float volume, float pitch) Plays a sound for the given player, but not for surrounding entities
-