If I were actually going to use a method like this in real life especially for international shipping etc, I’d probably avoid using rice or beans or other plant material to avoid unnecessary inspections at customs. I feel like this would definitely get stopped and inspected, where a block of multicoloured plastic or resin might not be.
I'd think that a block of resin would be equally suspicious, warranting an inspection immediately, but IANACBPO.
Otherwise, a block of (say) white icing sugar, encapsulated in a block of (opaque) resin, would pass a machine inspection and icing sugar-sniffing dogs at the border... and a lot of icing sugar would enter the country in a resin mold.
There are customs regulations against importing foodstuffs in many areas. For international travel or shipping, this might prove problematic on those grounds.
Rice, for example, is not allowed or might require specific permission to import into Australia. Coffee, noodles, pasta, pepper, and wheat might be restricted.