use of net.minecraft.block.SoundType in project SecurityCraft by Geforce132.
the class ItemReinforcedDoor method onItemUse.
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
*/
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(hand);
if (facing != EnumFacing.UP)
return EnumActionResult.FAIL;
else {
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (!block.isReplaceable(worldIn, pos))
pos = pos.offset(facing);
if (playerIn.canPlayerEdit(pos, facing, stack) && SCContent.reinforcedDoor.canPlaceBlockAt(worldIn, pos)) {
EnumFacing enumfacing = EnumFacing.fromAngle(playerIn.rotationYaw);
int i = enumfacing.getFrontOffsetX();
int j = enumfacing.getFrontOffsetZ();
boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
placeDoor(worldIn, pos, enumfacing, SCContent.reinforcedDoor, flag);
SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, playerIn);
worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
((TileEntityOwnable) worldIn.getTileEntity(pos)).getOwner().set(playerIn.getGameProfile().getId().toString(), playerIn.getName());
((TileEntityOwnable) worldIn.getTileEntity(pos.up())).getOwner().set(playerIn.getGameProfile().getId().toString(), playerIn.getName());
stack.shrink(1);
return EnumActionResult.SUCCESS;
} else
return EnumActionResult.FAIL;
}
}
use of net.minecraft.block.SoundType in project SecurityCraft by Geforce132.
the class ItemScannerDoor method onItemUse.
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
*/
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(hand);
if (facing != EnumFacing.UP)
return EnumActionResult.FAIL;
else {
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (!block.isReplaceable(worldIn, pos))
pos = pos.offset(facing);
if (playerIn.canPlayerEdit(pos, facing, stack) && SCContent.scannerDoor.canPlaceBlockAt(worldIn, pos)) {
EnumFacing enumfacing = EnumFacing.fromAngle(playerIn.rotationYaw);
int i = enumfacing.getFrontOffsetX();
int j = enumfacing.getFrontOffsetZ();
boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
placeDoor(worldIn, pos, enumfacing, SCContent.scannerDoor, flag);
SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, playerIn);
worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
((TileEntityOwnable) worldIn.getTileEntity(pos)).getOwner().set(playerIn.getGameProfile().getId().toString(), playerIn.getName());
((TileEntityOwnable) worldIn.getTileEntity(pos.up())).getOwner().set(playerIn.getGameProfile().getId().toString(), playerIn.getName());
stack.shrink(1);
return EnumActionResult.SUCCESS;
} else
return EnumActionResult.FAIL;
}
}
use of net.minecraft.block.SoundType in project SecurityCraft by Geforce132.
the class ItemScannerDoor method onItemUse.
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
*/
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (facing != EnumFacing.UP)
return EnumActionResult.FAIL;
else {
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (!block.isReplaceable(worldIn, pos))
pos = pos.offset(facing);
if (playerIn.canPlayerEdit(pos, facing, stack) && SCContent.scannerDoor.canPlaceBlockAt(worldIn, pos)) {
EnumFacing enumfacing = EnumFacing.fromAngle(playerIn.rotationYaw);
int i = enumfacing.getFrontOffsetX();
int j = enumfacing.getFrontOffsetZ();
boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
placeDoor(worldIn, pos, enumfacing, SCContent.scannerDoor, flag);
SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, playerIn);
worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
((TileEntityOwnable) worldIn.getTileEntity(pos)).getOwner().set(playerIn.getGameProfile().getId().toString(), playerIn.getName());
((TileEntityOwnable) worldIn.getTileEntity(pos.up())).getOwner().set(playerIn.getGameProfile().getId().toString(), playerIn.getName());
--stack.stackSize;
return EnumActionResult.SUCCESS;
} else
return EnumActionResult.FAIL;
}
}
use of net.minecraft.block.SoundType in project MorePlanets by SteveKunG.
the class ItemBlockSporelily method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
ItemStack itemStack = player.getHeldItem(hand);
if (!block.isReplaceable(world, pos)) {
pos = pos.offset(facing);
}
if (!itemStack.isEmpty() && player.canPlayerEdit(pos, facing, itemStack) && world.mayPlace(this.block, pos, false, facing, (Entity) null)) {
int i = this.getMetadata(itemStack.getMetadata());
IBlockState iblockstate1 = this.block.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player, hand);
if (this.placeBlockAt(itemStack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1)) {
SoundType sound = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
world.playSound(player, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume() + 1.0F) / 2.0F, sound.getPitch() * 0.8F);
itemStack.shrink(1);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
} else {
return EnumActionResult.FAIL;
}
}
use of net.minecraft.block.SoundType in project MorePlanets by SteveKunG.
the class ItemBlockSlabMP method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack itemStack = player.getHeldItem(hand);
if (this.block instanceof ISlabBlock) {
ISlabBlock singleSlab = (ISlabBlock) this.block;
if (itemStack.getCount() != 0 && player.canPlayerEdit(pos.offset(facing), facing, itemStack)) {
Object object = singleSlab.getHalf().getTypeForItem(itemStack);
IBlockState state = world.getBlockState(pos);
if (state.getBlock() == singleSlab.getHalf()) {
IProperty iproperty = singleSlab.getHalf().getVariantProperty();
Comparable comparable = state.getValue(iproperty);
EnumBlockHalf enumblockhalf = state.getValue(BlockSlab.HALF);
if ((facing == EnumFacing.UP && enumblockhalf == EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable == object) {
IBlockState state1 = singleSlab.getDouble().getDefaultState().withProperty(iproperty, comparable);
AxisAlignedBB axisalignedbb = state1.getCollisionBoundingBox(world, pos);
if (axisalignedbb != Block.NULL_AABB && world.checkNoEntityCollision(axisalignedbb.offset(pos)) && world.setBlockState(pos, state1, 11)) {
SoundType sound = singleSlab.getDouble().getSoundType(state1, world, pos, player);
world.playSound(player, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume() + 1.0F) / 2.0F, sound.getPitch() * 0.8F);
itemStack.shrink(1);
}
return EnumActionResult.SUCCESS;
}
}
return this.tryPlace(player, itemStack, world, pos.offset(facing), object, singleSlab.getHalf(), singleSlab.getDouble()) ? EnumActionResult.SUCCESS : super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
}
} else {
return EnumActionResult.FAIL;
}
return EnumActionResult.FAIL;
}
Aggregations