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)
| 25 | * @param side The side being right-clicked |
| 26 | */ |
| 27 | public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) |
| 28 | { |
| 29 | if (stack.stackSize == 0) |
| 30 | { |
| 31 | return false; |
| 32 | } |
| 33 | else if (!playerIn.canPlayerEdit(pos, side, stack)) |
| 34 | { |
| 35 | return false; |
| 36 | } |
| 37 | else |
| 38 | { |
| 39 | IBlockState iblockstate = worldIn.getBlockState(pos); |
| 40 | Block block = iblockstate.getBlock(); |
| 41 | BlockPos blockpos = pos; |
| 42 | |
| 43 | if ((side != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos)) |
| 44 | { |
| 45 | blockpos = pos.offset(side); |
| 46 | iblockstate = worldIn.getBlockState(blockpos); |
| 47 | block = iblockstate.getBlock(); |
| 48 | } |
| 49 | |
| 50 | if (block == this.block) |
| 51 | { |
| 52 | int i = iblockstate.getValue(BlockSnow.LAYERS); |
| 53 | |
| 54 | if (i <= 7) |
| 55 | { |
| 56 | IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, i + 1); |
| 57 | AxisAlignedBB axisalignedbb = this.block.getCollisionBoundingBox(worldIn, blockpos, iblockstate1); |
| 58 | |
| 59 | if (axisalignedbb != null && worldIn.checkNoEntityCollision(axisalignedbb) && worldIn.setBlockState(blockpos, iblockstate1, 2)) |
| 60 | { |
| 61 | worldIn.playSoundEffect((float)blockpos.getX() + 0.5F, (float)blockpos.getY() + 0.5F, (float)blockpos.getZ() + 0.5F, this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F); |
| 62 | --stack.stackSize; |
| 63 | return true; |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | return super.onItemUse(stack, playerIn, worldIn, blockpos, side, hitX, hitY, hitZ); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is |
nothing calls this directly
no test coverage detected