Possible issue with Improved Sleeping
NielsPilgaard opened this issue · 10 comments
Hey!
I'm not certain this bug is actually caused by Quark, but it might be.
Beds randomly stop functioning on servers with the Quark improved sleeping system enabled - You can lie in them, but it doesn't skip the night.
It doesn't appear to have a trigger, and it solves itself after a random amount of time, without restarting the server.
Would a forced crash log help tracking the issue down?
The servers in question have also had the mod Bed Patch, so I've opened a very similar issue on that tracker: Mordenkainen/BedPatch#1 (comment)
We are also having this issue on our server, and have termed this the "Sleeping Beauty Disorder". We have no other mods that influence sleeping in anyway, but I currently cannot test this in an isolated environment.
I should also note that this will only occur for individual players. I may be able to sleep fine, but someone else may have issues.
I honestly have no idea where to start with this one. I've never had it happen in my entire time playing on a quark server.
If you have the time to test this extensively, you can see if it happens with only quark, and if not, add in mods bit by bit until it does.
@SirDavidLudwig Does your server have the Bed Patch mod on it?
@Mordenkainen It does not
@Vazkii Is it possible this may be due to not updating the players AFK flag if they are the only player on the server:
https://github.com/Vazkii/Quark/blob/master/src/main/java/vazkii/quark/tweaks/feature/ImprovedSleeping.java#L55
That almost looks like there could be cases where the client changes it's flag state, but the server ignores the packet because they are the only player. If the player was AFK, but the only player on the server, the packet will get sent via "onClientTick", but the flag will not get changed. Then, since "timeSinceKeystroke" is already greater than "afkTime" the packet is never sent again, resulting in a player which should be marked AFK but isn't, or vice versa.
Just taking a guess here, assuming I am reading the code correctly.
EDIT - Yeah, I think this is exactly the issue:
- Player A goes AFK with others on the server.
- Other players log off.
- Player A comes back, packet is sent to clear AFK flag, and is ignored by the server. This packet will not be resent unless the player goes AFK and comes back again.
- Player A tries to sleep, Minecraft never triggers the sleep cycle because legitPlayers is not > 0 Here, due to Player A being marked as AFK.
- If other players attempt to sleep, Player A is ignored (they are AFK).
Other symptoms of this should include:
- Players in this state will not be included as either sleeping or non-sleeping players lists during status messages.
- Players who AFK when other players are on, only coming back when no one else is on, will not see the notification that they stopped AFKing.
Unfortunately I am unable to test this theory anytime in the near future.
@Mordenkainen That is exactly what it is, I'm encountering this problem right now, I went afk, my friend left, I came back and I never got the message that I was unafk and I can no longer sleep, rejoining doesn't fix it either.
Edit: Just wanted to add as a distinction from the original report, for me now that I'm in this bugged afk state, no matter how many times I relaunch my client or reconnect, I can't sleep throuhg the night, I assume I'll need to reboot the server.
I tried adding a bit to the ImprovedSleeping to basically unmark you as afk if the playercount is 1 and afk is true, didn't work out just ended up spamming afk/no longer afk messages.
Funnilly enough as I was typing this out, I went afk, and I went back and it unmarked me as afk since someone was on and now it's resolved, so uh ¯\_(ツ)_/¯
That fits with my review of the code. If you are in this state, just wait until another player is on the server, let yourself go AFK, then start playing again. This should clear the issue.
Yep, that's how I've been able to fix it. Interestingly enough though, I've just had it happen that I went afk with three people on the server, someone left, I came back, and I'm still afk. There's currently two people on the server but it's not marking me as back, still waiting to go afk to see if that fixes it, this seems like a seperate issue though.