Called when a Block is right-clicked with this Item @param pos The block being right-clicked @param side The side being right-clicked
(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
| 48 | * @param side The side being right-clicked |
| 49 | */ |
| 50 | public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) |
| 51 | { |
| 52 | if (stack.stackSize == 0) |
| 53 | { |
| 54 | return false; |
| 55 | } |
| 56 | else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack)) |
| 57 | { |
| 58 | return false; |
| 59 | } |
| 60 | else |
| 61 | { |
| 62 | Object object = this.singleSlab.getVariant(stack); |
| 63 | IBlockState iblockstate = worldIn.getBlockState(pos); |
| 64 | |
| 65 | if (iblockstate.getBlock() == this.singleSlab) |
| 66 | { |
| 67 | IProperty iproperty = this.singleSlab.getVariantProperty(); |
| 68 | Comparable comparable = iblockstate.getValue(iproperty); |
| 69 | BlockSlab.EnumBlockHalf blockslab$enumblockhalf = iblockstate.getValue(BlockSlab.HALF); |
| 70 | |
| 71 | if ((side == EnumFacing.UP && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable == object) |
| 72 | { |
| 73 | IBlockState iblockstate1 = this.doubleSlab.getDefaultState().withProperty(iproperty, comparable); |
| 74 | |
| 75 | if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3)) |
| 76 | { |
| 77 | worldIn.playSoundEffect((float)pos.getX() + 0.5F, (float)pos.getY() + 0.5F, (float)pos.getZ() + 0.5F, this.doubleSlab.stepSound.getPlaceSound(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getFrequency() * 0.8F); |
| 78 | --stack.stackSize; |
| 79 | } |
| 80 | |
| 81 | return true; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | return this.tryPlace(stack, worldIn, pos.offset(side), object) ? true : super.onItemUse(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) |
| 90 | { |
nothing calls this directly
no test coverage detected