ModsFinder

Somnus API

by TheIllusiveC4

Somnus API is a Fabric library that exposes events and hooks for the vanilla sleep mechanic, so other mods can change how sleeping works.

FabricClient or server, optionalGNU Lesser General Public License v3.0 or laterOpen source1.16.5 – 1.17.1

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

  1. Wake time control

    Sets the time of day at which players wake up, so a mod can shorten or lengthen the night.

  2. Sleep attempt hook

    Blocks a sleep attempt before it begins, letting a mod deny sleeping under its own conditions.

  3. Valid sleep times

    Defines which times of day count as valid for sleeping, replacing the vanilla rule when needed.

  4. Wake-up events

    Fires an event when a player wakes, so other code can run at that moment.

  5. 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.

No stable releases
Every published file is a beta or alpha build.
1.17.10.0.14-1.17.1
1.16.50.0.12-1.16.5
ReleaseBetaAlphaNot available

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?

Only Fabric. Files are published for Minecraft 1.16.5 and 1.17.1, with 0.0.14-1.17.1 as the latest file for 1.17.1.

Does a server need Somnus API installed?

Not necessarily. The library can run on a client alone, a server alone or both, and neither side is required to have it.

Which mods require Somnus API?

The Modrinth page does not list mods that depend on it, so no dependent mods are named here.

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

All projects

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.
TheIllusiveC4, on the Modrinth page

Official listing

Owner
TheIllusiveC4
Published
2023-02-10
Updated on Modrinth
2023-02-10
Facts verified
2026-10-15

Tags