minecraft:rotation_axis_aligned for you with a switch.Get GodCraftOverview
minecraft:rotation_axis_aligned is an entity component: it goes in the components object of a custom mob, or in one of its component groups. Snaps the entity to face the closest of the four main directions. Pair it with body_rotation_blocked to keep its body locked to that direction.
Example
Inside the components object of BP/entities/<name>.json (values are the defaults or placeholders):
BP/entities/<name>.json
{
"minecraft:rotation_axis_aligned": {}
}