Villagers either don't sleep or don't wake up
We have a long time world that was originally created on android in 2017, moved to win10, and finally put on a realm. it's currently a bit under 400mb. Sometime during the 1.14 release, all the villagers in the game got a permanent case of insomnia and narcolepsy – the ones that are awake never sleep, the ones that are asleep never wake up.
I don't remember when exactly it happened, but when we noticed we restored from what should have been working backup and nothing changed. We decided to wait for 1.16 as there were a number of reported villager bugs and nothing has changed
I downloaded a copy of the realm to windows 10, switched to creative mode for some debugging. Here's what we've found:
- villagers everywhere have this problem, if I teleport to somewhere completely new and find a newly generated village, the villagers are stuck in the same locked cycle (usually awake and wandering around)
- This affects villagers that were naturally generated, bred, summoned, and spawned froman egg
- villagers are able to link to both beds and workstations. we have a trading hall setup in the middle of nowhere – about 200 blocks away from the nearest village (all our previous trading halls in the main areas kept having link issues
- setting the time manually or waiting out the time makes no difference.
- narcoleptic villagers
- if i break their bed, they wake up and sometimes walk, but never restock with their workstation
- placing a new bed they'll immediately link and go to sleep if they can pathfind to it
- if I trade with them, they'll wake up for the trade then go immediately back to sleep
- if I can quickly break the bed before they get back in, they'll still immediately link to the next placed bed and go to sleep.
- wake up if take damage from me, mob, or environment (fire, blocks)
- turn into witches if lightning'ed
- if i ring the bell, they'll all wake up, look around for a bit, then go back to bed
- if i break their bed, they wake up and sometimes walk, but never restock with their workstation
- insomniac villagers
- link to any workstation and bed placed in range
- relink any number of times to workstations and beds
- never restock their trades
- turn into witches if lightninged
Other village mechanics like iron golems and cat spawning seem to continue, but not as quickly as before.
I have tried switching modes (survival, creative, adventure) and difficulties (peaceful, easy, etc). we have a command block for single person sleeping and i've tried with cheats enabled and disabled, command blocks toggled, breaking the command block, and pretty much anything else I can think of.
Attached are some screenshots taken in the trading hall.
I can't reproduce this in a new world,
This doesn't seem related to existing bug reports i've seen as linking works very consistently in a controlled environment (the trading hall), there are no nitwits involved, and it consistently affects each villager across versions and platforms.
appreciate any assistance
Linked Issues
- Duplicate
FG
- 2
- 4
- Unconfirmed
- Survival
- Multiple
- Realm, Windows 10, Android 10
- 1.15.0.9 RTX Beta 1.16.0
Created Issue:
Villagers either don't sleep or don't wake up
We have a long time world that was originally created on android in 2017, moved to win10, and finally put on a realm. it's currently a bit under 400mb. Sometime during the 1.14 release, all the villagers in the game got a permanent case of insomnia and narcolepsy – the ones that are awake never sleep, the ones that are asleep never wake up.
I don't remember when exactly it happened, but when we noticed we restored from what should have been working backup and nothing changed. We decided to wait for 1.16 as there were a number of reported villager bugs and nothing has changed
I downloaded a copy of the realm to windows 10, switched to creative mode for some debugging. Here's what we've found:
- villagers everywhere have this problem, if I teleport to somewhere completely new and find a newly generated village, the villagers are stuck in the same locked cycle (usually awake and wandering around)
- This affects villagers that were naturally generated, bred, summoned, and spawned froman egg
- villagers are able to link to both beds and workstations. we have a trading hall setup in the middle of nowhere – about 200 blocks away from the nearest village (all our previous trading halls in the main areas kept having link issues
- setting the time manually or waiting out the time makes no difference.
- narcoleptic villagers
- if i break their bed, they wake up and sometimes walk, but never restock with their workstation
- placing a new bed they'll immediately link and go to sleep if they can pathfind to it
- if I trade with them, they'll wake up for the trade then go immediately back to sleep
- if I can quickly break the bed before they get back in, they'll still immediately link to the next placed bed and go to sleep.
- wake up if take damage from me, mob, or environment (fire, blocks)
- turn into witches if lightning'ed
- if i ring the bell, they'll all wake up, look around for a bit, then go back to bed
- insomniac villagers
- link to any workstation and bed placed in range
- relink any number of times to workstations and beds
- never restock their trades
- turn into witches if lightninged
Other village mechanics like iron golems and cat spawning seem to continue, but not as quickly as before.
I have tried switching modes (survival, creative, adventure) and difficulties (peaceful, easy, etc). we have a command block for single person sleeping and i've tried with cheats enabled and disabled, command blocks toggled, breaking the command block, and pretty much anything else I can think of.
Attached are some screenshots taken in the trading hall.
I can't reproduce this in a new world,
This doesn't seem related to existing bug reports i've seen as linking works very consistently in a controlled environment (the trading hall), there are no nitwits involved, and it consistently affects each villager across versions and platforms.
appreciate any assistance
- Unresolved
- Open
- Unconfirmed
- Multiple
- Realm, Windows 10, Android 10
- 1.15.0.9 RTX Beta 1.16.0
relates to
duplicates
relates to
Based on this report and duplicate report MCPE-86843, villagers display the following problems when a world's Time exceeds 2^31, or 89,478 game-days. This would be equivalent to just under 3.5 real-world years of runtime if players never slept in-game; 1.75 years of runtime if they slept every night. Some 1-player sleep systems may cause this issue to occur sooner than it would otherwise.
- Will not sleep
- Will not wake up naturally (they can be woken by the player, but will try to sleep again)
- Will not refresh trades
- May not spawn iron golems
Original summary
Integer Overrun Error causes villagers not to restock.
When the Time goes over 2147471640 (approximate, probably 2,147,483,648=2^31), it becomes negative.
Once the time is negative, advancing days is applied inconsistently to other times and timers. In particular, villagers do not restock. Villagers would still not restock after breaking and re-placing their workstations, which is what led me to discover this bug.
This can be fixed by setting the time to 0 if it is negative.
This occurred on a realm, so I reproduced it using command blocks for this bug report.
Possibly the same issue as MCPE-86843.
This does appear to be the cause of linked "MCPE-86843 Villagers either don't sleep or don't wake up".
Coming in from MCPE-86843 here.
This bug affects local worlds as well as realms. Although we started keeping a persistent world in preparation for the better together update, I've owned MCPE on android since 2011 and could potentially have nearly 9 year old maps. As I reported in the other bug, we ran the world as a server with a 24/7 dummy account for over a year and even without single player sleep command blocks we'd be hitting 3.5 years already.
Does this affect BDS as well? or does time stop progressing on BDS when no one is connected?
I've done some digging and discovered that the Time variable in level.dat actually skips ahead by up to 12000 even during normal player sleep, so the issue here is less related to one-player sleep systems than we thought. Time is used to keep track of the daylight cycle. The difference between the present value of Time and the nearest multiples of 24000 determines which part of the day the world is at. Time increments with each tick if dodaylightcycle is on, and it advances to the next multiple of 24000 when players sleep. According to MCPE-43394, the /time set command always increases Time, either by advancing to a later part of the present day, or by advancing to the next day when setting an earlier time-of-day than present. Howerver, /time set never adds more than 24000 to Time.
There is no special coding to handle Time naturally incrementing beyond 2^31. It simply rolls over to -2^31 and continues to increment. When it does so, it triggers the problems described in this report. Here is my test:
- Create a world with dodaylightcycle on.
- Spawn a villager and place a bed and workstation so that it links.
- Using an NBT editor, edit Time to be close to 2^31.
- Open the world and wait.
- After observing that the villager either doesn't go to bed at night or doesn't work in the daytime, close the world and check Time with the NBT editor. It will be negative.
There is another variable in level.dat that keeps track of the world's total running time: currentTick. This variable actually increments beyond 2^31 and even 2^32 without issue. It stays positive. In my 2 local survival worlds that have never had cheats enabled, Time is 20-25% higher than currentTick. In Francois Gurin's level.dat (from MCPE-86843) currentTick is at 546,663,823. That corresponds to about 316 real-world days of running time. It doesn't seem to fit his year of 24/7 running but it is a big number nonetheless.






I managed to resolve the issue by downloading the world & replacing the level.dat with a copy from a newly created world with the same seed.
I haven't tracked down the exact dates, but it looks like the actual bug is that Realms corrupted our level.dat, and that the corrupted level.dat affected the sleep cycle of the villagers.
Can this bug be moved to realms or should it be closed and a new one opened?
Following with same issue, and tried most of what OP has tried. Might try the level.dat thing...can anyone say what else the level.dat will affect?
Do you still have a copy of the level.dat that was causing the problem? I am wondering if you had the same issue described here:
MCPE-98361.The report will automatically reopen when you reply.
Replying via email did not reopen. I will post the messages and files directly
I downloaded the realm backup from July and it looks like that is far enough back that the problem still exists. I've attached the level.dat to this email, and will try to upload it to the issue if that doesn't work.
(if you have access to the realms environment you can also see all the world files)
It does sound related to
MCPE-98361, this is a long time world that has been through all gamemodes, and we were running 1 player sleep systems that would mess with timeFrom memory, the 1 player sleep was a basic 2 command block system that set time to a specific hour early morning and cleared weather. It used the execute that used to trigger if you were even standing on the pillow of the bed. More recently we switched to FoxyNoTails 1 player sleep resource pack. If it's important I can pull out the commands from the old system or try to see if i can find when we switched to the resource pack.
hth
Adding to the time integer limitations:
Before moving this world to a realm, we were hosting it on an android device and later a win10 system. We had setup an extra account and left the world running 24/7 for at least a year.
This was before bedrock server was out.
It is not unreasonable for worlds to hit 3+ years of gametime. Thank you for continuing to look into this and make the game better for us all.
And to comfirm, loaded the backup world in MCC Toolchest and time was negative as you expected. Changed it to positive and the villagers sleep cycle returned to normal
Thanks Francois for following up. The e-mail replay system is not reliable, unfortunately. Based on what you've said, I am going to forward-resolve this report as a duplicate of
MCPE-98361and add a note about the additional information you've provided.