Program: 12677
Project: 12677
Buggy source:
@Override public EnumActionResult onItemUse(ItemStack stack,EntityPlayer player,World world,BlockPos pos,EnumHand hand,EnumFacing side,float hitX,float hitY,float hitZ){
  if (side != EnumFacing.UP) {
    return EnumActionResult.FAIL;
  }
  if (world.isRemote)   return EnumActionResult.PASS;
  IBlockState iblockstate=world.getBlockState(pos);
  Block block=iblockstate.getBlock();
  boolean replaceable=block.isReplaceable(world,pos);
  if (!replaceable) {
    pos=pos.up();
  }
  int direction=MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3;
  EnumFacing facing=EnumFacing.getHorizontal(direction);
  BlockPos other=pos.offset(facing);
  boolean other_replaceable=block.isReplaceable(world,other);
  boolean flag1=world.isAirBlock(pos) || replaceable;
  boolean flag2=world.isAirBlock(other) || other_replaceable;
  if (player.canPlayerEdit(pos,side,stack) && player.canPlayerEdit(other,side,stack)) {
    if (flag1 && flag2 && UtilLib.doesBlockHaveSolidTopSurface(world,pos.down())&& UtilLib.doesBlockHaveSolidTopSurface(world,other.down())) {
      IBlockState state1=ModBlocks.coffin.getDefaultState().withProperty(BlockCoffin.OCCUPIED,Boolean.FALSE).withProperty(BlockCoffin.PART,BlockCoffin.EnumPartType.FOOT).withProperty(BlockCoffin.FACING,facing);
      if (world.setBlockState(pos,state1,3)) {
        IBlockState state2=state1.withProperty(BlockCoffin.PART,BlockCoffin.EnumPartType.HEAD).withProperty(BlockCoffin.FACING,facing);
        world.setBlockState(other,state2,3);
      }
      --stack.stackSize;
      return EnumActionResult.SUCCESS;
    }
  }
  return EnumActionResult.FAIL;
}

Fixed version (ground truth):
@Override public EnumActionResult onItemUse(ItemStack stack,EntityPlayer player,World world,BlockPos targetPos,EnumHand hand,EnumFacing side,float hitX,float hitY,float hitZ){
  if (side != EnumFacing.UP) {
    return EnumActionResult.FAIL;
  }
  if (world.isRemote)   return EnumActionResult.PASS;
  IBlockState iblockstate=world.getBlockState(targetPos);
  Block block=iblockstate.getBlock();
  boolean replaceable=block.isReplaceable(world,targetPos);
  BlockPos pos=replaceable ? targetPos : targetPos.up();
  int direction=MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3;
  EnumFacing facing=EnumFacing.getHorizontal(direction);
  BlockPos other=pos.offset(facing);
  boolean other_replaceable=block.isReplaceable(world,other);
  boolean flag1=world.isAirBlock(pos) || replaceable;
  boolean flag2=world.isAirBlock(other) || other_replaceable;
  if (player.canPlayerEdit(pos,side,stack) && player.canPlayerEdit(other,side,stack)) {
    if (flag1 && flag2 && UtilLib.doesBlockHaveSolidTopSurface(world,pos.down())&& UtilLib.doesBlockHaveSolidTopSurface(world,other.down())) {
      IBlockState state1=ModBlocks.coffin.getDefaultState().withProperty(BlockCoffin.OCCUPIED,Boolean.FALSE).withProperty(BlockCoffin.PART,BlockCoffin.EnumPartType.FOOT).withProperty(BlockCoffin.FACING,facing);
      if (world.setBlockState(pos,state1,3)) {
        IBlockState state2=state1.withProperty(BlockCoffin.PART,BlockCoffin.EnumPartType.HEAD).withProperty(BlockCoffin.FACING,facing);
        world.setBlockState(other,state2,3);
      }
      --stack.stackSize;
      return EnumActionResult.SUCCESS;
    }
  }
  return EnumActionResult.FAIL;
}