This is a continuation of ExtraCrafTX's BetterSleeping mod, ported to 1.17+ and rewritten for better compatibility and native support for 1.17's new `playersSleepingPercentage` gamerule.
Sleep recovery
Sleep recovery gives players regeneration for 15s when they have slept through the night. This can be adjusted in the config.
No-sleep debuffs
No-sleep debuffs are applied when a player has skipped three nights consecutively without sleeping. The effects get stronger and last longer the more nights the player is awake. This can be enabled or disabled, and the nights before the effect is applied can be configured through the config file as well.
The effects given are:
- Slowness
- Weakness
- Nausea
- Mining fatigue
- Blindness
(Effects and timing are configurable)
Messages
Messages are sent when a player sleeps, for skipping nights and for debuffs. These can all be configured as well. Each message can have placeholders that are replaced:
- The night skipped message does not take any placeholders.
- The players asleep message can take:
- `{asleepPlayers}` which is replaced with the number of players asleep
- `{totalPlayers}` which is replaced with the total number of players
- `{asleepPercentage}` which is replaced with the percentage of players that are asleep
- `{asleepPlayersRequired}` which is replaced with the number of players required to skip the night
- `{asleepPercentageRequired}` which is replaced with the percentage of players required to skip the night
- `{asleepPlayersAdditionallyNeeded}` which is replaced with the number of players additionally needed to sleep to skip the night
- The debuff message can take `{nightsAwake}` which is replaced with the number of nights skipped.
The config file also has a formatting field that is used to format the messages. It is a list and can take the names of any of the standard colours and styles. The Minecraft wiki has a full list.
Config
The config file is found in the config folder and is called `bettersleeping.toml`. This folder should be in the same place as your mods folder (`.minecraft` for Windows). If this file is deleted the mod will recreate it with the default settings at the next start-up. If you're in singleplayer, you can also use the in-game configuration menu (via ModMenu)!
Hi, i use this mod in my server, but... i don't have the option to set amount of player need sleep
I have this
[messages]
nightSkippedMessage = "Rise and shine!"
sendNightSkippedMessageToEveryone = false
debuffMessage = "Ha estado despierto durante {nightsAwake} Ha estado despierto durante {nightsAwake} noches y se le ha aplicado una desventaja.."
playersAsleepMessage = "{asleepPlayers}/{totalPlayers} ({asleepPercentage}%) jugadores ahora están durmiendo"
notEnoughPlayersAsleepMessage = "{asleepPlayers}/{totalPlayers} ({asleepPercentage}%) jugadores ahora están durmiendo. {asleepPlayersAdditionallyNeeded} más son requeridos para saltar la noche!"
messageFormatting = ["gold"]
Help me please ♥
Already answered in the Discord server, but for other users having the same question: It's the `/gamerule playersSleepingPercentage` command! It exists in vanilla MC since 1.17 ;)
so i put false for the debuff in the config but it is not disabling them everyone still keeps getting heavy debuff if they fail to sleep (the percentage required to skip the day is currently 50%)
Sorry for the late reply, but are you sure you've changed the actual server config? Not just the client setting?
In reply to NebelNidas:
yes the server has "applyAwakeDebuffs = false" in the config have not changed anything on the client
Did you change it in the correct file? The latest version uses `bettersleeping.toml`, while older versions used `bettersleeping_config.json5`Edit: I checked the code, and it turns out the check whether debuffs should be applied or not got deleted somehow 🤦♂️ I'll release a bugfix as soon as possible!
Edit 2: It's out now!
In reply to NebelNidas:
sweet. thanks.
Hi hi,
I don't know if this is an issue, if it is not a feature, or one that can be implemented.
I'm playing on a personal server with this mod installed and "Time & Wind (Fabric). I edited the length of the day and night to around 30 minutes in total, and deactivated night skip too.
I don't know if you are familiar with the mod, it accelerates the TPS so the night goes faster with someone asleep.
The "issue" comes from the fact that this mod doesn't trigger, since there is no night skip. it does not give the regeneration buff, and as far as I'm aware, it doesn't apply any de-buff - This may be due to the fact that the mod checks that we have interacted with the bed resetting the timer.
Could it be possible to apply the regen buff even if there is no night skip? I didn't find anything in the configs.
If it is too hard, or annoying just forget it. I'll work around it.
Thanks for (re)creating this amazing mod :) (And for reading the giant text)
In reply to Silverbolt_24:
I had a similar issue trying to use this with Time & Wind.
In my experience, it seemed to be inaccurately detecting the number of days that had passed. My best guess is there's a counter of ticks/time since last slept. That's likely divided by the assumed day length to get how long it's been since your last nap. For me. the day and night lengths were both extended, so after about 2 days in game the mod said I hadn't slept in over 5 days.
A potential solution (for the mod maker) would be to have the mod log the day count on the night the player sleeps, then check if the difference between that and the current day count match at set times of day. That said, I'm sure it's not that simple. It would probably require querying the day time every x ticks or something.
In reply to wilevar:
Hi,
If I'm not mistaken, on vanilla Minecraft the tick time related to sleep reset each time you lay down on a bed.
A clear example of this is that you can lay down on a bed at the start of the night, get immediately up, be awake the rest of the night, do this several nights and you'll notice phantoms will not spawn.
Another potential solution would checking if the player interacted with a bed, sleeping bag, or something similar, that makes night ticking change (and define on this mod how much time in ticks refers to night and day).
But I'm a noob, so this may not be even feasible.
In reply to Silverbolt_24:
Detecting that interaction and resetting a timer/tick counter is certainly possible. The issue is still the length of the counter not matching an extended day/night cycle.
The solution most other mods use when their functions are day-length dependent is to add a config variable for day cycle length. Some examples would be Serene Seasons, and Enhanced Celestials. Both have a config value for day length because their primary functions change by the day, so they need to know how many days have passed.
Without that, if Time and Wind makes the day length 2 or 3 times normal, then they'd track several days passing in one, which is one of the issues people run into here.
I think Better Sleeping is resetting it's sleep tracking on the "wake Up" event after you stay in bed all night. I could be wrong, but that's how I would have done it to make sure players actually sleep rather than just laying down and getting back up immediately.
In reply to wilevar:
It makes a lot of sense what you said. Unfortunately I am not able to do anything to solve this since I have no knowledge of programming (unfortunately :-( )
Let's see if it is updated tho :)
(And actually, thanks for the chat :D)
First of all, thanks for reporting this issue! BetterSleeping is using vanilla functionality where possible, to ensure mod compat. The problem is that MC doesn't have a way of getting the max day length, so we're just hardcoding it: bettersleeping/events/EventHandlerBase.java#L42
There are several occasions in this file where we divide by 24000 ticks, the expected length of a Minecraft day. I could add compat code for Time & Wind, but that's an uphill battle with the ever increasing amount of mods being available. So I think the best option is to add a config entry for the amount of ticks a day has, like @wilvar suggested 👍
As for the issue with not receiving any (de)buffs after having slept, either that's also related to us relying on the 24000 ticks (see here) or Time & Wind bypasses the `onWakeUp` method. I'll try to look into it over the next days
In reply to NebelNidas:
Hey hey,
Thank you for replying :D and good luck
fabric noob forge plssss
Maybe in the future, but I don't think I have time for that
i don't have this option in cpnfig
im using mod in 1.18.1 fabric|
.....
nvm we have to use gamerule in game
Sorry for the very late reply, I've somehow missed your message. I've completely rewritten the config system in the latest release, please make sure to check if that resolves the issue you were having :)
Likely a stupid question to ask but server side or client side mod?
It's only required on the server! :) But you're right, I should add it to the description 👍