Prepare the crust: If using a pastry crust, fully blind-bake it and let it cool completely. A fully baked crust prevents sogginess.
Whisk the dry mix: In a medium saucepan, whisk sugar, cocoa powder, cornstarch, and salt until no lumps remain.
This helps the custard thicken evenly.
Add dairy gradually: Whisk in the milk and 3/4 cup of the heavy cream a little at a time until smooth. Turn the heat to medium.
Cook to thicken: Cook, whisking constantly, until the mixture thickens and gently bubbles, 5–8 minutes. It should coat the back of a spoon and leave a trail when you run a finger through it.
Temper the yolks: In a small bowl, whisk the egg yolks.
Slowly stream in about 1/2 cup of the hot mixture while whisking constantly. Then pour the tempered yolks back into the saucepan, whisking well.
Finish cooking: Cook 1–2 minutes more, whisking, until glossy and thick. Do not let it boil hard—gentle bubbles are enough.
Add chocolate and flavor: Remove from heat.
Stir in the chopped chocolate, butter, and vanilla until completely smooth.
Strain (optional but smart): For an ultra-smooth custard, pass the filling through a fine-mesh sieve into a bowl.
Fill the crust: Pour the warm filling into the cooled pie crust. Smooth the top with a spatula.
Prevent skin: Press a piece of plastic wrap directly onto the surface of the filling.
Chill to set: Refrigerate at least 4 hours, preferably overnight, until fully set.
Make whipped cream: In a chilled bowl, whip 1 cup cold heavy cream with powdered sugar and vanilla to soft peaks. Spread or pipe over the chilled pie.
Garnish and serve: Add chocolate shavings or a light cocoa dusting.
Slice with a sharp knife wiped clean between cuts.