Somnus API
Somnus API is a Fabric library that exposes events and hooks for the vanilla sleep mechanic, so other mods can change how sleeping works.
What it does
Developers use the library to decide whether a given time of day counts as valid for sleeping, and to determine when players wake up. Its events let a mod prevent a sleep attempt from starting, and they let a mod react when a player wakes. Vertical offsets applied to sleeping players can also be changed through the same interface, which matters for beds placed in unusual positions.
Somnus API is a lightweight library, and it is meant to be used alongside other sleep mechanics on Fabric rather than to replace them. It is published only for Fabric, for Minecraft 1.17.1 and 1.16.5. Either side can run it, and neither needs it. The source code is open source under the GNU Lesser General Public License v3.0 or later, and the project publishes its issue tracker.
Key features
Wake time control
Sets the time of day at which players wake up, so a mod can shorten or lengthen the night.
Sleep attempt hook
Blocks a sleep attempt before it begins, letting a mod deny sleeping under its own conditions.
Valid sleep times
Defines which times of day count as valid for sleeping, replacing the vanilla rule when needed.
Wake-up events
Fires an event when a player wakes, so other code can run at that moment.
Sleeping offset
Changes the vertical offset applied to a sleeping player, for beds and similar blocks.
Compatibility
Latest build for each game version and loader.
Only full game releases are shown. This mod publishes no snapshot builds.
Use cases
Custom night length
A mod can make nights shorter on a survival server by changing the wake time through the library.
Restricted sleeping
A mod can block sleep attempts in certain areas or conditions by using the sleep attempt hook.
Who it’s for: Mod developers building Fabric sleep mechanics, and server owners who run mods that depend on this library. Players who only want to sleep in vanilla do not need it.
Questions
Which loader does Somnus API support?
Does a server need Somnus API installed?
Which mods require Somnus API?
In the catalog
Somnus API is one of 3,514 Library mods on ModsFinder, and one of 2,348 Library mods for Fabric. 4,181 mods support Minecraft 1.17.1.
More from TheIllusiveC4
Similar mods
What the author says
Somnus is a lightweight library that adds a few events for sleeping in Minecraft to allow mod developers easy and compatible ways of implementing their sleep mechanics on Fabric.
Official listing
- Modrinth page
- modrinth.com/mod/somnus
- Owner
- TheIllusiveC4
- Published
- 2023-02-10
- Updated on Modrinth
- 2023-02-10
- Facts verified
- 2026-10-15
