The bug
When lightning hits a villager that is sleeping in a bed, the villager will turn into a witch, and the bed will stay occupied forever.
To reproduce
Place a bed
Spawn a villager next to it
Set time to night
Run
/summon minecraft:lightning_bolt ~ ~ ~
while on the bedThe villager turns into a witch and leaves the bed
Right-click onto the bed
→ ❌ The message "This bed is occupied" appears
Code analysis
Code analysis and potential fix can be found in this comment.
Linked issues
is duplicated by 5
relates to 2
Attachments
Comments 20
Comfirmed for 20w17a, 20w18a, 20w19a, 20w20a, 20w21a, 20w22a, 1.16 Pre-Release, 1.16 Pre-Release 2, 1.16 Pre-release 3, 1.16 Pre-Release 4, 1.16 Pre-Release 5.
This occurs because witches have the capability to store a bed location in their entity data exactly like villagers. The minecraft:home (bed coordinates) from the struck villager is preserved when spawning the witch entity.
The easiest fix would be to clear the bed from the list of POIs when the lightning strike happens, and to NOT preserve the bed location when spawning the witch.