The way this works is that each block has a structural strength value that's defined by the blocks underneath and next to it. Going from one block to the next, different materials lose different amounts of strength, as they are more or less suited to supporting things horizontally, vertically, or diagonally.
For example, stone blocks can be stacked up very tall, but they're not good at supporting things horizontally or diagonally, so for roofs you want to switch to wood.
Materials also have a maximum amount of structural strength they can transmit, so for example, canvas can't really carry much atop of it.
Finally, there's also a penalty for having both horizontally adjacent blocks be air, which means that double-thickness walls are stronger, especially for the crumblier materials.
This implementation (source) is a naive 2D one, so it's not efficient at all, but with a large 3D world it should be possible to only have to recalculate local effects when a block is added/removed, so the performance would be OK.