Search in sources :

Example 1 with SimpleSoundInstance

use of net.minecraft.client.resources.sounds.SimpleSoundInstance in project Tropicraft by Tropicraft.

the class ScubaAmbienceTicker method play.

private static void play(SoundEvent sound) {
    if (currentSound != sound) {
        stop();
        currentSound = sound;
        Minecraft.getInstance().getSoundManager().play(new SimpleSoundInstance(sound.getLocation(), SoundSource.AMBIENT, 0.4f, 1.0f, true, 0, SoundInstance.Attenuation.NONE, 0.0F, 0.0F, 0.0F, true));
    }
}
Also used : SimpleSoundInstance(net.minecraft.client.resources.sounds.SimpleSoundInstance)

Example 2 with SimpleSoundInstance

use of net.minecraft.client.resources.sounds.SimpleSoundInstance in project Applied-Energistics-2 by AppliedEnergistics.

the class BlockTransitionEffectPacket method playBreakOrPickupSound.

@Environment(EnvType.CLIENT)
private void playBreakOrPickupSound() {
    SoundEvent soundEvent;
    float volume;
    float pitch;
    if (soundMode == SoundMode.FLUID) {
        // This code is based on what BucketItem does
        Fluid rawFluid = blockState.getFluidState().getType();
        if (rawFluid.is(FluidTags.LAVA)) {
            soundEvent = SoundEvents.BUCKET_FILL_LAVA;
        } else {
            soundEvent = SoundEvents.BUCKET_FILL;
        }
        volume = 1;
        pitch = 1;
    } else if (soundMode == SoundMode.BLOCK) {
        SoundType soundType = blockState.getSoundType();
        soundEvent = soundType.getBreakSound();
        volume = soundType.volume;
        pitch = soundType.pitch;
    } else {
        return;
    }
    SimpleSoundInstance sound = new SimpleSoundInstance(soundEvent, SoundSource.BLOCKS, (volume + 1.0F) / 2.0F, pitch * 0.8F, pos);
    Minecraft.getInstance().getSoundManager().play(sound);
}
Also used : SoundType(net.minecraft.world.level.block.SoundType) SoundEvent(net.minecraft.sounds.SoundEvent) Fluid(net.minecraft.world.level.material.Fluid) SimpleSoundInstance(net.minecraft.client.resources.sounds.SimpleSoundInstance) Environment(net.fabricmc.api.Environment)

Example 3 with SimpleSoundInstance

use of net.minecraft.client.resources.sounds.SimpleSoundInstance in project MoreBoots by North-West-Wind.

the class MusicBootsItem method onPlaySound.

@OnlyIn(Dist.CLIENT)
@Override
public void onPlaySound(PlaySoundEvent event) {
    LocalPlayer player = Minecraft.getInstance().player;
    if (player == null)
        return;
    SoundInstance sound = event.getSound();
    event.setSound(new SimpleSoundInstance(INSTRUMENTS.get(player.getRandom().nextInt(INSTRUMENTS.size())), SoundSource.RECORDS, 1, (float) Math.pow(2.0D, (double) (player.getRandom().nextInt(24) - 12) / 12.0D), sound.getX(), sound.getY(), sound.getZ()));
}
Also used : LocalPlayer(net.minecraft.client.player.LocalPlayer) SoundInstance(net.minecraft.client.resources.sounds.SoundInstance) SimpleSoundInstance(net.minecraft.client.resources.sounds.SimpleSoundInstance) SimpleSoundInstance(net.minecraft.client.resources.sounds.SimpleSoundInstance) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 4 with SimpleSoundInstance

use of net.minecraft.client.resources.sounds.SimpleSoundInstance in project SimpleMuseum by DenimRed.

the class ClientUtil method playArbitrarySound.

/**
 * Plays a given sound by name. Primarily exists to suppress {@linkplain OnlyIn} exceptions.
 */
public static void playArbitrarySound(ResourceLocation soundName, SoundSource source, Vec3 pos, float volume, float pitch) {
    final SimpleSoundInstance instance = new SimpleSoundInstance(soundName, source, volume, pitch, false, 0, SoundInstance.Attenuation.LINEAR, pos.x, pos.y, pos.z, false);
    MC.getSoundManager().play(instance);
}
Also used : SimpleSoundInstance(net.minecraft.client.resources.sounds.SimpleSoundInstance)

Example 5 with SimpleSoundInstance

use of net.minecraft.client.resources.sounds.SimpleSoundInstance in project atomicstrykers-minecraft-mods by AtomicStryker.

the class MultiMineClient method renderBlockDigParticles.

/**
 * Helper method to emulate the Digging Particles created when a player mines a Block. This usually runs every tick while mining
 *
 * @param x coordinate of Block being mined
 * @param y coordinate of Block being mined
 * @param z coordinate of Block being mined
 */
private void renderBlockDigParticles(int x, int y, int z) {
    Level world = thePlayer.getLevel();
    BlockPos bp = new BlockPos(x, y, z);
    BlockState state = world.getBlockState(bp);
    Block block = state.getBlock();
    if (block != Blocks.AIR) {
        SoundType soundtype = block.getSoundType(state, world, bp, thePlayer);
        mc.getSoundManager().play(new SimpleSoundInstance(soundtype.getHitSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 8.0F, soundtype.getPitch() * 0.5F, bp));
    }
    world.addDestroyBlockEffect(bp, state);
}
Also used : SoundType(net.minecraft.world.level.block.SoundType) BlockState(net.minecraft.world.level.block.state.BlockState) PartiallyMinedBlock(atomicstryker.multimine.common.PartiallyMinedBlock) Block(net.minecraft.world.level.block.Block) SimpleSoundInstance(net.minecraft.client.resources.sounds.SimpleSoundInstance) Level(net.minecraft.world.level.Level) BlockPos(net.minecraft.core.BlockPos)

Aggregations

SimpleSoundInstance (net.minecraft.client.resources.sounds.SimpleSoundInstance)5 SoundType (net.minecraft.world.level.block.SoundType)2 PartiallyMinedBlock (atomicstryker.multimine.common.PartiallyMinedBlock)1 Environment (net.fabricmc.api.Environment)1 LocalPlayer (net.minecraft.client.player.LocalPlayer)1 SoundInstance (net.minecraft.client.resources.sounds.SoundInstance)1 BlockPos (net.minecraft.core.BlockPos)1 SoundEvent (net.minecraft.sounds.SoundEvent)1 Level (net.minecraft.world.level.Level)1 Block (net.minecraft.world.level.block.Block)1 BlockState (net.minecraft.world.level.block.state.BlockState)1 Fluid (net.minecraft.world.level.material.Fluid)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1