Search in sources :

Example 6 with SoundEvent

use of net.minecraft.util.SoundEvent in project minecolonies by Minecolonies.

the class EntityAIWorkFisherman method playNeedRodSound.

/**
     * Plays a sound when the fisherman needs a rod.
     */
private void playNeedRodSound() {
    if (worker != null) {
        final SoundEvent needFishingRod = worker.isFemale() ? FishermanSounds.Female.needFishingRod : FishermanSounds.Male.needFishingRod;
        SoundUtils.playSoundAtCitizenWithChance(world, worker.getPosition(), needFishingRod, CHANCE_TO_PLAY_SOUND);
    }
}
Also used : SoundEvent(net.minecraft.util.SoundEvent)

Example 7 with SoundEvent

use of net.minecraft.util.SoundEvent in project minecolonies by Minecolonies.

the class DeliverymanSounds method playSaturationSound.

/**
     * Play the saturation sound depending on the saturation.
     *
     * @param worldIn    world to play it in.
     * @param position   position to play it at.
     * @param isFemale   the gender.
     * @param saturation the saturation.
     */
public void playSaturationSound(final World worldIn, final BlockPos position, final boolean isFemale, final double saturation) {
    //While there are no male sounds
    if (!isFemale) {
        return;
    }
    final SoundEvent saturationFeedback;
    if (saturation < EntityCitizen.LOW_SATURATION) {
        saturationFeedback = Female.saturationVeryLow;
    } else if (saturation < EntityCitizen.AVERAGE_SATURATION) {
        saturationFeedback = Female.saturationLow;
    } else {
        saturationFeedback = Female.saturationHigh;
    }
    SoundUtils.playSoundAtCitizenWithChance(worldIn, position, saturationFeedback, getBasicSoundChance());
}
Also used : SoundEvent(net.minecraft.util.SoundEvent)

Example 8 with SoundEvent

use of net.minecraft.util.SoundEvent in project minecolonies by Minecolonies.

the class FishermanSounds method playSound.

/**
     * Plays fisherman sounds.
     *
     * @param worldIn  the world to play the sound in.
     * @param position the position to play the sound at.
     * @param isFemale the gender.
     */
@Override
public void playSound(final World worldIn, final BlockPos position, final boolean isFemale, final double saturation) {
    //Leaving it as switch-case we may add further random sound categories here (Whistling, singing, etc).
    switch(rand.nextInt(NUMBER_OF_SOUNDS + 1)) {
        case 1:
            final SoundEvent generalPhrases = isFemale ? FishermanSounds.Female.generalPhrases : FishermanSounds.Male.generalPhrases;
            SoundUtils.playSoundAtCitizenWithChance(worldIn, position, generalPhrases, getPhraseChance());
            break;
        case 2:
            final SoundEvent noises = isFemale ? FishermanSounds.Female.noises : FishermanSounds.Male.noises;
            SoundUtils.playSoundAtCitizenWithChance(worldIn, position, noises, getBasicSoundChance());
            break;
        default:
            break;
    }
}
Also used : SoundEvent(net.minecraft.util.SoundEvent)

Example 9 with SoundEvent

use of net.minecraft.util.SoundEvent in project minecolonies by Minecolonies.

the class EntityAIWorkFisherman method playCaughtFishSound.

/**
     * Plays a sound with a chance when a fish has been caught.
     */
private void playCaughtFishSound() {
    if (worker != null) {
        final SoundEvent iGotOne = worker.isFemale() ? FishermanSounds.Female.iGotOne : FishermanSounds.Male.iGotOne;
        SoundUtils.playSoundAtCitizenWithChance(world, worker.getPosition(), iGotOne, CHANCE_TO_PLAY_SOUND);
    }
}
Also used : SoundEvent(net.minecraft.util.SoundEvent)

Example 10 with SoundEvent

use of net.minecraft.util.SoundEvent in project minecolonies by Minecolonies.

the class DeliverymanSounds method playSound.

/**
     * Plays fisherman sounds.
     * Suppressing Sonar Rule squid:S109
     * This rule wants to prevent magic numbers
     * But in this case the rule does not apply because its not a magic number its a % chance.
     * For every sound category we have 1 increasing number.
     *
     * @param worldIn    the world to play the sound in.
     * @param position   the position to play the sound at.
     * @param isFemale   the gender.
     * @param saturation the saturation.
     */
@SuppressWarnings(MAGIC_NUMBERS_SHOULD_NOT_BE_USED)
@Override
public void playSound(final World worldIn, final BlockPos position, final boolean isFemale, final double saturation) {
    //While there are no male sounds
    if (!isFemale) {
        return;
    }
    //Leaving it as switch-case we may add further random sound categories here (Whistling, singing, etc).
    switch(rand.nextInt(NUMBER_OF_SOUNDS + 1)) {
        case 1:
            final SoundEvent noises = DeliverymanSounds.Female.noises;
            SoundUtils.playSoundAtCitizenWithChance(worldIn, position, noises, getBasicSoundChance());
            break;
        case 2:
            playSaturationSound(worldIn, position, isFemale, saturation);
            break;
        default:
            final SoundEvent generalPhrases = DeliverymanSounds.Female.generalPhrases;
            SoundUtils.playSoundAtCitizenWithChance(worldIn, position, generalPhrases, getPhraseChance());
            break;
    }
}
Also used : SoundEvent(net.minecraft.util.SoundEvent)

Aggregations

SoundEvent (net.minecraft.util.SoundEvent)17 ResourceLocation (net.minecraft.util.ResourceLocation)7 Nonnull (javax.annotation.Nonnull)3 ItemStack (net.minecraft.item.ItemStack)3 SoundType (net.minecraft.block.SoundType)2 IBlockState (net.minecraft.block.state.IBlockState)2 IFluidHandlerItem (net.minecraftforge.fluids.capability.IFluidHandlerItem)2 Block (net.minecraft.block.Block)1 BlockLiquid (net.minecraft.block.BlockLiquid)1 Material (net.minecraft.block.material.Material)1 ISound (net.minecraft.client.audio.ISound)1 PositionedSound (net.minecraft.client.audio.PositionedSound)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 PlaySoundEvent (net.minecraftforge.client.event.sound.PlaySoundEvent)1 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)1 VoidFluidHandler (net.minecraftforge.fluids.capability.templates.VoidFluidHandler)1 BlockLiquidWrapper (net.minecraftforge.fluids.capability.wrappers.BlockLiquidWrapper)1 BlockWrapper (net.minecraftforge.fluids.capability.wrappers.BlockWrapper)1 FluidBlockWrapper (net.minecraftforge.fluids.capability.wrappers.FluidBlockWrapper)1