private boolean placeBlock(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xOffset, float yOffset, float zOffset) { IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); if(!block.isReplaceable(world, pos)) { pos = pos.offset(side); } if(itemstack.isEmpty()) { return false; } else if(!player.canPlayerEdit(pos, side, itemstack)) { return false; } else if(world.mayPlace(Blocks.MOB_SPAWNER, pos, false, side, null)) { int meta = this.getMetadata(itemstack.getMetadata()); IBlockState iblockstate1 = Blocks.MOB_SPAWNER.getStateForPlacement(world, pos, side, xOffset, yOffset, zOffset, meta, player); if (placeBlockAt(itemstack, player, world, pos, side, xOffset, yOffset, zOffset, iblockstate1)) { world.playSound(null, pos, Blocks.MOB_SPAWNER.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (Blocks.MOB_SPAWNER.getSoundType().getVolume() + 1.0F) / 2.0F, Blocks.MOB_SPAWNER.getSoundType().getPitch() * 0.8F); player.renderBrokenItemStack(itemstack); itemstack.shrink(1); for(int i = 0; i < 100; i++) Botania.proxy.sparkleFX(pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6); } return true; } else { return false; } }
.getSoundHandler() .playSound( new PositionedSoundRecord( block.getSoundType() .getBreakSound(), SoundCategory.BLOCKS, ( block.getSoundType().getVolume() + 1.0F ) / 2.0F, block.getSoundType() .getPitch() * 0.8F, (float) this.x + 0.5F, (float) this.y + 0.5F, (float) this.z + 0.5F ) );
block1 = Blocks.FARMLAND; world.playSound(null, pos, block1.getSoundType().getStepSound(), SoundCategory.BLOCKS, (block1.getSoundType().getVolume() + 1.0F) / 2.0F, block1.getSoundType().getPitch() * 0.8F);
@Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { BlockPos pos = data.readBlockPos(); VisualFXType visualFX = VisualFXType.values()[data.readByte()]; SoundFXType soundFX = SoundFXType.values()[data.readByte()]; World world = player.world; IBlockState blockState = NBTUtil.readBlockState(data.readCompoundTag()); Block block = blockState.getBlock(); if (visualFX == VisualFXType.BLOCK_BREAK) { Minecraft.getMinecraft().effectRenderer.addBlockDestroyEffects(pos, blockState); } if (soundFX != SoundFXType.NONE) { SoundType soundType = block.getSoundType(blockState, world, pos, null); if (soundFX == SoundFXType.BLOCK_BREAK) { world.playSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, soundType.getBreakSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F, false); } else if (soundFX == SoundFXType.BLOCK_PLACE) { world.playSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F, false); } } } }
public static void playHitSound(@Nonnull SoundType snd, @Nonnull World world, @Nonnull BlockPos pos) { SoundHelper.playSound(world, pos, new Sound(snd.getHitSound()), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F); }
public static void playSoundPlaceBlock(World world, BlockPos pos, Block block) { if (block == null) { return; } SoundType type = block.getSoundType(block.getDefaultState(), world, pos, null); if (type != null && type.getPlaceSound() != null) { UtilSound.playSound(world, pos, type.getPlaceSound(), SoundCategory.BLOCKS); } }
if (fireTicks == 10) { world.playSound(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, EsteemedInnovation.SOUND_HISS, SoundCategory.BLOCKS, Blocks.ANVIL.getSoundType().getVolume(), 0.9F, false);
@Override @SideOnly(Side.CLIENT) public void actionClient(World world, EntityPlayer player) { Block block = Block.getBlockById(blockID); world.playSound(x, y, z, block.getSoundType().getBreakSound(), SoundCategory.BLOCKS, 0.1F + world.rand.nextFloat() * 0.5F, 0.9F + world.rand.nextFloat() * 0.1F, false); ParticleBloodSplash.spawnParticles(world, new BlockPos((int) x, (int) y + 1, (int) z), 3 + world.rand.nextInt(2), 1 + world.rand.nextInt(2)); }
public static void playSoundPlaceBlock(EntityPlayer player, BlockPos pos, Block block) { if (player == null) { return; } BlockPos here = (pos == null) ? player.getPosition() : pos; if (block == null) { return; } SoundType type = block.getSoundType(block.getDefaultState(), player.getEntityWorld(), here, player); if (type != null && type.getPlaceSound() != null) { UtilSound.playSound(player, here, type.getPlaceSound()); } }
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { // Copy of ItemBlock.onItemUse IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); if (!block.isReplaceable(world, pos)) { pos = pos.offset(facing); } ItemStack stack = player.getHeldItem(hand); if (!stack.isEmpty() && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(ModBlocks.buriedPetals, pos, false, facing, null)) { int i = this.getMetadata(stack.getMetadata()); IBlockState iblockstate1 = ModBlocks.buriedPetals.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player); if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1)) { SoundType soundtype = ModBlocks.buriedPetals.getSoundType(); world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); stack.shrink(1); } return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }
event.getEntityPlayer().swingArm(event.getHand()); else { event.getWorld().playSound(null, event.getPos(), block.getSoundType().getBreakSound(), SoundCategory.BLOCKS, block.getSoundType().getVolume() * 0.4F, block.getSoundType().getPitch() + (float) (Math.random() * 0.2 - 0.1));
public static void playStepSound(@Nonnull SoundType snd, @Nonnull World world, @Nonnull BlockPos pos) { SoundHelper.playSound(world, pos, new Sound(snd.getStepSound()), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F); }
this.decrStackSize(slot, 1); SoundType type = UtilSound.getSoundFromBlockstate(stateToMatch, world, posTarget); if (type != null && type.getPlaceSound() != null) { int dim = this.getDimension(); int range = 18; UtilSound.playSoundFromServer(type.getPlaceSound(), SoundCategory.BLOCKS, posTarget, dim, range);
public static void playPlaceSound(@Nonnull SoundType snd, @Nonnull World world, @Nonnull BlockPos pos) { SoundHelper.playSound(world, pos, new Sound(snd.getPlaceSound()), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F); }
public static void playBreakSound(@Nonnull SoundType snd, @Nonnull World world, @Nonnull BlockPos pos) { SoundHelper.playSound(world, pos, new Sound(snd.getBreakSound()), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F); }
/** * Plays step sound at given x, y, z for the entity */ public void playStepSound(BlockPos entityPos, Block block) { // no sounds for eggs or underwater action if (dragon.isEgg() || dragon.isInWater()) { return; } // override sound type if the top block is snowy SoundType soundType; if (dragon.worldObj.getBlockState(entityPos.up()).getBlock() == Blocks.SNOW_LAYER) { soundType = Blocks.SNOW_LAYER.getSoundType(); } else { soundType = block.getSoundType(); } // play stomping for bigger dragons SoundEvent stepSound; if (dragon.isHatchling()) { stepSound = soundType.getStepSound(); } else { stepSound = getStepSound(); } playSound(stepSound, soundType.getVolume(), soundType.getPitch()); }
@Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); IBlockState state = worldIn.getBlockState(pos); Block block = worldIn.getBlockState(pos).getBlock(); if(block instanceof BlockFirePitOff) { int meta = block.getMetaFromState(state); if(meta < 3) { worldIn.playSound(null, pos, SoundType.WOOD.getPlaceSound(), SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); worldIn.setBlockState(pos, state.withProperty(BlockFirePit.STAGE, meta + 1)); stack.shrink(1); return EnumActionResult.SUCCESS; } return EnumActionResult.FAIL; } return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } }
private void playBlockSound(World world, RayTraceResult hit, IBlockState state) { SoundType sound = state.getBlock().getSoundType(state, world, hit.getBlockPos(), null); if (sound != null) { world.playSound(null, hit.getBlockPos(), sound.getPlaceSound(), SoundCategory.BLOCKS, sound.getVolume() * 0.5F, sound.getPitch() * 0.8F); } }
public static void breakSound( final World world, final BlockPos pos, final int extractedState ) { final IBlockState state = ModUtil.getStateById( extractedState ); final Block block = state.getBlock(); world.playSound( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, DeprecationHelper.getSoundType( block ).getBreakSound(), SoundCategory.BLOCKS, ( DeprecationHelper.getSoundType( block ).getVolume() + 1.0F ) / 16.0F, DeprecationHelper.getSoundType( block ).getPitch() * 0.9F, false ); }