I heard its illegal to grow your own coffee or chocolate plants. is this true? I'm in California, USA if that matters.
You heard incorrectly. Unfortunately, both crops require a tropical environment. While you may be able to create these at home [California contains no tropical zones], it will be labor intensive with no guarantee of success.
It depends on what part of CA you are in for the coffee. I'm in San Pedro, zone 10B and we grow coffee here outdoors. It need frost protection and a true freeze, temps 32F and below, will kill it. You can see coffee growing at the Quail botanical gardens in SD and at the OC Fairgrounds. Chocolate, Cacao, is a different story. It's an Ultra-Tropical and can't take temps below 55-60. It does, however, do very well as an indoor house plant here, but takes a real green thumb to get it to thrive. Both are legal to grow and they are commonly sold on Ebay.
You can grow them indoors as house plants just about anywhere if you maintain the right conditions. I believe that you need at least one other tree of each for cross pollination.
It is not illegal to grow these plants. Cacao is a very large plant and I do not believe it would be possible to grow this plant to maturity and fruiting indoors, and outside will require considerable space. It is not in the least hardy, so will require the warmest tropical climate for successful cultivation. Coffee plants are readily available in most garden centers with a houseplant department. I have seen very nice starts in 4 inch pots at Home Depot. The plants are beautiful shrubs with glossy deep green leaves which in conditions the plant likes (humid jungle -- indoors provide a location in a window which gets lots of bright light but little direct sun, and mist daily, or even a couple times a day, to boost the humidity the plant craves for optimal growth. In warm climate zones, coffee may be grown successfully, but they are also very tender, although not as unforgiving as the cacao. In time, when the plant is sufficiently mature, it will bloom with deliciously fragrant white blossoms. When the plant finishes blooming, the spent flowers develop into showy red berries, which contain the coffee beans. It is unlikely that you would be able to grow enough houseplants, in the home garden, or even in a large home greenhouse to obtain enough coffee beans for use. Think of how many beans there are in a one-pound package of whole bean coffee, and how many cups of coffee you are able to get out of it. You would need to devote a large parcel of land and farm the plants for any reasonable production. However, as I said, Coffee plants are top-notch houseplants or warm-climate shrubs in all seasons, and an interesting conversation piece.