use of net.minecraft.block.SoundType in project ImmersiveEngineering by BluSunrize.
the class ItemToolbox method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (!block.isReplaceable(world, pos))
pos = pos.offset(side);
if (stack.stackSize != 0 && player.canPlayerEdit(pos, side, stack) && world.canBlockBePlaced(IEContent.blockMetalDecoration2, pos, false, side, null, stack)) {
IBlockState toolbox = IEContent.blockMetalDecoration2.getStateFromMeta(BlockTypes_MetalDecoration2.TOOLBOX.getMeta());
if (world.setBlockState(pos, toolbox, 3)) {
IEContent.blockMetalDecoration2.onIEBlockPlacedBy(world, pos, toolbox, side, hitX, hitY, hitZ, player, stack);
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
--stack.stackSize;
}
return EnumActionResult.SUCCESS;
} else
return EnumActionResult.FAIL;
}
return super.onItemUse(stack, player, world, pos, hand, side, hitX, hitY, hitZ);
}
use of net.minecraft.block.SoundType in project ImmersiveEngineering by BluSunrize.
the class ItemCoresample method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (!block.isReplaceable(world, pos))
pos = pos.offset(side);
if (stack.stackSize != 0 && player.canPlayerEdit(pos, side, stack) && world.canBlockBePlaced(IEContent.blockStoneDevice, pos, false, side, null, stack)) {
IBlockState toolbox = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.CORESAMPLE.getMeta());
if (world.setBlockState(pos, toolbox, 3)) {
IEContent.blockStoneDevice.onIEBlockPlacedBy(world, pos, toolbox, side, hitX, hitY, hitZ, player, stack);
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
--stack.stackSize;
}
return EnumActionResult.SUCCESS;
} else
return EnumActionResult.FAIL;
}
return super.onItemUse(stack, player, world, pos, hand, side, hitX, hitY, hitZ);
}
use of net.minecraft.block.SoundType in project minecolonies by Minecolonies.
the class EntityAIWorkLumberjack method plantSapling.
/**
* Plant a sapling at said location.
*
* @param location the location to plant the sapling at
* @return true if a sapling was planted
*/
private boolean plantSapling(@NotNull final BlockPos location) {
final Block worldBlock = world.getBlockState(location).getBlock();
if (worldBlock != Blocks.AIR && !(worldBlock instanceof BlockSapling)) {
return false;
}
final int saplingSlot = findSaplingSlot();
if (saplingSlot != -1) {
final ItemStack stack = getInventory().getStackInSlot(saplingSlot);
final Block block = ((ItemBlock) stack.getItem()).getBlock();
worker.setHeldItem(saplingSlot);
placeSaplings(saplingSlot, stack, block);
final SoundType soundType = block.getSoundType(world.getBlockState(location), world, location, worker);
world.playSound(null, this.worker.getPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS, soundType.getVolume(), soundType.getPitch());
worker.swingArm(worker.getActiveHand());
this.getOwnBuilding().getColony().incrementStatistic("saplings");
}
if (job.tree.getStumpLocations().isEmpty() || timeWaited >= MAX_WAITING_TIME) {
timeWaited = 0;
setDelay(TIMEOUT_DELAY);
return true;
}
timeWaited++;
return false;
}
use of net.minecraft.block.SoundType in project Railcraft by Railcraft.
the class SoundHelper method playPlaceSoundForBlock.
public static void playPlaceSoundForBlock(World world, BlockPos pos) {
IBlockState state = WorldPlugin.getBlockState(world, pos);
Block block = state.getBlock();
SoundType soundType = block.getSoundType(state, world, pos, null);
playSound(world, null, pos, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F);
}
use of net.minecraft.block.SoundType in project AgriCraft by AgriCraft.
the class TileEntityCrop method setCrossCrop.
@Override
public boolean setCrossCrop(boolean status) {
// If remote, change was failure.
if (this.isRemote()) {
return false;
}
// If we have a plant, change was a failure.
if (this.hasSeed()) {
return false;
}
// If the new state does not differ, change was a failure.
if (this.crossCrop == status) {
return false;
}
// Otherwise perform change.
this.crossCrop = status;
SoundType type = Blocks.PLANKS.getSoundType(null, null, null, null);
worldObj.playSound(null, (double) ((float) xCoord() + 0.5F), (double) ((float) yCoord() + 0.5F), (double) ((float) zCoord() + 0.5F), type.getPlaceSound(), SoundCategory.BLOCKS, (type.getVolume() + 1.0F) / 2.0F, type.getPitch() * 0.8F);
this.markForUpdate();
// Operation was a success!
return true;
}
Aggregations