Bat spawn egg spawns bat inside non-full block.
Affected blocks:
Soul sand
Honey block
Farmland
Drit path
Snow layers 8
Slab
Sea pickle
Big dripleaf
Chorus plant
Chest
Trapped chest
Ender chest
Cactus
Chain(axis: x, z)
Enchanting table
End portal frame
Flower pot
Skull or head
Grindstone
Stonecutter
Bell
Lantern
Soul lantern
Campfire
Soul campfire
Candle
Small amethyst bud
Medium amethyst bud
Large amethyst bud
Amethyst cluster
Pointed dripstone
Hopper
Lectern
Daylight detector
Turtle egg
Conduit
Cake
Brewing stand
Mud
Sculk shrieker
Sculk sensor
Carpet
Moss carpet
Flower pot
Lightning rod(facing: east, west, north, south)
End rod(facing: east, west, north, south)
Calibrated sculk sensor
Use the following command:
Bat(Reconfirmed in 19w14a)
/give @p bat_spawn_egg{EntityTag:{id:"minecraft:bat",NoAI:1b}} 1
Code analysis
Based on 1.11 decompiled using MCP 9.35 rc1
For bats the method net.minecraft.entity.passive.EntityBat.onUpdate()
is causing this which sets their y position to floor(y) + 1 - height
if it is hanging.
Related issues
is duplicated by
relates to
Attachments
Comments

This issue relates to MC-108226.

Removed gamemode because you can use spawn eggs in survival mode as well
Since shulkers and bats could be different issues, decided to split the ticket.
Now this ticket is only about bats.
Shulker is MC-174876.

Also applies to farmland and grass paths.
Can confirm in 21w03a.
Can confirm in 21w05a.
Can confirm in 21w05b.
Can confirm in 21w06a.
Can confirm in 21w07a.
Video attached.
Can confirm in 21w11a.
Can confirm in 21w13a.
Can confirm in 21w17a.
Can confirm in 1.17.
Can confirm in 1.18.
Can confirm in 1.18.1.
Can confirm in 1.18.2.
Can confirm in 21w11a. This same concept can also be seen with mud.