Detect what face of a block you are looking at

My question is simple. How do I know what face or location of a block is the mouse looking at?
I know how to use the mouseOver sensor to detect the mouse over a block, and I read about using a ray to detect things. But, how do I know if I am looking at the top, side, or bottom of a block like you would in Minecraft or Dragon Quest Builders or other games?

RayCast*can get PolyProxy

Alternatively we can raycast in local space using a bvhtree (mathutils)

In 3x I use bvhtree lib to interact with geometry nodes for instance using drived mesh

Could you give me an example?

I also learned that I can get the hitPosition of the mouseOver event.

import bge, mathutils, bpy

cont = bge.logic.getCurrentController()

own = cont.owner
deps = bpy.context.evaluated_depsgraph_get()


if cont.sensors['Mouse_Over'].positive:
   HP = cont.sensors['Mouse_Over'].hitPosition
   hitOb = cont.sensors['Mouse_Over'].hitObject
   if 'bvh' not in hitOb:
       hitOb['bvh']= mathutils.bvhtree.BVHTree.fromObject(hitOb.blenderObject,deps)
   closest = hiOb['bvh'].find_nearest( hitOb.worldTransform.inverted() @ HP)

   index = closest[2]

   poly = ob.blenderObject.polygons[index]

this is for meshes not edited by modifiers,

we can use ‘evaluated object’ to do that