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));
}
}
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);
}
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()));
}
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);
}
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);
}
Aggregations