Credits for the original suggestion goes to this Reddit post.
When a Mineshaft generates, there is a chance of it being haunted. Haunted mineshafts are similar to regular mineshafts, but with several differences:
- Torches will randomly appear and disappear within sight range of the player.
- Walking particles appear randomly so it looks like invisible players are walking. Floating items and shadows can appear too.
- Footstep sounds and distant sounds of blocks being placed or broken can be heard.
- The player occasionally appears to take damage and makes the damage sound (but takes no knockback so it doesn't knock them off of high places)
- Mobs can occasionally spawn in higher light levels than usual, and as close as 8 blocks to the player (as opposed to further than 24 blocks).
- All of the above effects could happen more frequently the closer the player is to the bottom of the world.
Similarly, there could be Haunted versions of zombie/abandoned villages. During nighttime, the village would have similar effects as haunted mineshafts.
These structures should contain better loot than regular Mineshafts/villages to give players an incentive to face the dangers.
Alternatively, all mineshafts and abandoned villages generate normally, but have a chance of becoming haunted for a period of time (which would also improve the loot of any unopened loot chests in that structure).