This is how you code an undermesh prevention

a few reasons why this wont work it is far too resource intensive, raycasting will cost a ton of power between network and client at least and you just cant raycast the map(world mesh) and expect that to do it as the map itself is suprisingly flat and barren, most undermesh is built into rocks etc(game environment assets) because of this, so you would need constant building raycast checks on each single object whenever a player is attempting to place an object, given the kitbash nature of the world the normal information of the mesh is likely to include inconsistencies and overlapping, you could for instance be placing an undermesh foundation in a hollowspace between rocks or the outside of the mesh to a non level area where its attaching to a world object but not inside any object (the main map being a flat plane its normal is facing forever upward and normals on objects forever outward).

realistically I thought myself the best way to solve this would be a simple secondary collision smaller than the mesh which would both teleport players to the desert and do undermesh checks however this again wouldnt solve the hollow space problem and this would be extremely costly to do (as you would likely need to make a new custom collision box for every world object in the game) but the word is funcom has already designed some new anti undermesh tech so we will have to see what they come up with.