The bug
When using a spawn egg on the top face of a short block (tested with trapdoors and carpets), the mob will spawn on top of the block above the targeted block, instead of on top of the targeted block itself.
To reproduce
Place a stack of two carpets on the ground
Try to spawn a villager on the bottom carpet
Observed behaviour
The villager spawns on the top carpet
Expected behaviour
The villager would spawn on the bottom carpet (i.e. the targeted block surface)
Notes
Adding more carpets won't cause the villager to spawn even higher
Screenshots
[media]Related issues
is duplicated by
relates to
Attachments
Comments


I think this is working as intended, because it wouldn’t make any sense for the entity to spawn inside an adjacent block (carpet/trapdoor in this case).

I agree with @AJ8967, since it would just be suffocating, or stuck

That is true, however, when another carpet is added on top, the mob spawns within the top carpet instead of in a clear area. In addition, the mob has explicitly been placed by the player, so it should spawn where the player wants it to.
Edit: It looks like the bug has now been triaged by Mojang
Can confirm in 1.19.