Updated description by @unknown
Steps to reproduce
Find or build a village with at least 1 farmer, 1 other villager, and a food supply.
Add beds to the village until there are more beds than villagers.
Position the player such that:
some beds and workstations are outside of simulation distance,
villagers can move across the simulation distance boundary in the direction of those beds, and
the farmer's bed, workstation, and farm, and at least one other bed, remain accessible to villagers within simulation distance.
Wait at least 25 minutes.
Expected result
The villagers breed until villagers >= beds.
Actual result
The villagers continue to breed even after villagers >= beds.
Test world
I have attached a test world that reproduces this bug:
The world consists of a village similarly sized and shaped to the one described by Tim Roush in this comment. It has 26 beds in rooms around a 40 x 40 central square: 4 beds north, 8 west, 8 south, and 6 east. The player is situated on a platform to the south of the village such that the beds to the north (and, by accident, some on the east) are outside of simulation distance. To the right of the player is a pair of command blocks that recount the loaded villagers when you press the button.
The village has already been run following the steps above for about an hour. There are presently 32 villagers within the village walls. However, if you load the world and press the button you will get a count of 11 because 21 are outside of simulation distance. The village data (viewed with MCCToolChest) shows 19 villagers registered to the village. 6 of these have TS timers > 15000 (showing that they've been outside of simulation distance > 15 minutes); 5 of those 6 along with 12 others can found beyond the northern central wall that runs along Z = -1, just outside of simulation distance. The other high-TS registered villager and 3 others are just outside of simulation distance in the northern rooms east of the central village. As soon as you load the world villagers will begin to breed. If you remain on the glowstone platform they will continue to breed as villagers wander out of simulation distance and their TS timers expire.
Original summary
Villagers breed to double the bed count
Original description
Doing some testing, but it seems like villagers breed to double the bed count, causing old villagers to forget their beds and workspace blocks, and causing overpopulation. This MAY be the cause of the bug where villages expand
STEPS TO REPRODUCE:
Build a village in any world and set up more than 1 bed
Make one villager a farmer, and the others whatever you want
Make a small farm for the villagers to use
The farmer will begin harvesting and distributing the food
After some time, villagers will begin wanting to breed (hearts will appear around them)
You'll notice that when a baby is born, the old villager seems to be exiled from the village, and will forget its bed and workspace block, and begin wandering aimlessly around and outside the village.
Again, this may be the cause of the village expansion bug where villagers claim blocks thousands of blocks away from the actual village.
Linked issues
is duplicated by 17
relates to 2
Attachments
Comments 33
That screenshot made me chuckle. An orgy of irresponsible breeding! ...and yet, the rabbits in the game don't act this way, but probably should, if there are enough predators to balance the population.
In the case of this farm, is it possible that its design is too spread out, causing some villagers to be separated from their beds by too far a distance, and they de-link? I understand a villager can detect a job site block as far as 48 blocks away. The same detection range may apply to beds – that is, a villager loses its claim on a job site block or a bed if it goes beyond 48 blocks from them. Might that be an issue here (that it isn't working as expected)? Or maybe the breeding criteria are disconnected from employment and sleeping?
I have a similar type of issue. I have an underground village built with a house, bed, and workstation for every villager. It was great since the update as the economy was very worth building up. But now every time I load the area either by travel or load the game, 3 villagers will abandon their beds and trigger the village to produce 3 more babies. Babies can be among those that abandon the beds as well. What's worse is if I place 3 more beds to accommodate the surplus, the villagers that abandoned their original beds will not claim a new one, and instead it triggers the village to produce yet again, three more babies. And of course, now that they do not sleep, the original abandoners will no longer refresh their trades. I assume this is some kind of issue with the village possibly spanning over the border of a chunk? I'm not sure if mine does, but it seems like a likely cause. Xbox One S / Realms / Bedrock
@unknown: To clarify, I don't think that the overbreeding is causing the villagers to forget their beds and workstations, I think it's the other way around. It starts with the "exiled" villagers forgetting that they dwell in this village for some reason (which is the actual bug). A villager can only claim a bed and workstation in a village they dwell in, so they automatically release their claims, leaving their former beds and workstations available. The remaining villagers then notice there are unclaimed beds and breed to fill them.
We've been aware that there are problems with the stability of villager/village relationships, but it seems to happen randomly so it's tough trying to catch it in the act. I'll be trying to reproduce this. If I can, hopefully it'll be the key to solving a bunch of related problems (which, yes, might include expanding villages).
@unknown: The villager to bed or workstation distance thing is actually a bit more complicated than that. Basically, it's the village that holds the knowledge about what POI blocks (beds, workstations, and bells) it contains. Villagers have to discover them initially, which they can only do up 16 blocks away horizontally and 4 blocks vertically, but once they do discover them, they add them to the village. At that point any villager who dwells in the village, no matter where he is in the world, becomes aware that they exist, and whoever's turn it is can claim them. So in other words, a villager can't detect a bed or workstation 48 blocks away, but they can claim one at any distance, as long as some villager in the same village detected it at some point. Note that although the village remembers where its POI blocks are, the game doesn't give the villagers access to that information. Unless they're within the 16-block detection range, they only know that it exists, not where it is. This is the reason that some villagers wander around for a while after sunset; they're trying to find their beds. (I don't know why they designed it to work this way.)
@unknown: I would be very interested in getting a copy of the world in your screenshot, if you still have it.
I have added some (hopefully correct) repros for an issue that sounds very much like this one in the job MCPE-155980
Also included is how I almost fixed it, and where it feels like the problem comes from.
I went from 4 extra villagers without beds to just the 1 by just mining and re-adding all the beds 1 by 1, then adding more beds for the bedless villagers while watching out for breeding. Whether it's something out of sync on the bed or the villager or the "village" I don't know.
To stop this:
Villagers need to check nearby unloaded chunks before breeding, or refrain until all village chunks are loaded? Might come back and bite us.
Have an occasional catch-up when the player is in the village with all the chunks loaded, to make sure "villager knowledge of beds for breeding purposes" and "actual bed count" are in sync.
I've retested this bug in 1.19.2 Hotfix using the attached test world, and the village only populates until the number of villagers loaded after the fix to MCPE-43071 reaches the bed count. In other words, the overpopulation only occurs where there are villagers who have never been loaded since before 1.16.200. That makes sense, because villagers who have not been loaded since before 1.16.200 do not have the last_saved_pos
data that was added in 1.16.200 to fix MCPE-43071, so they still get dropped from the village when they are not ticked for 20 minutes while the village is being ticked. When all villagers have the last_saved_pos
data then the overpopulation does not occur using the steps in the description.
I am not sure now how to explain reports of overpopulation since 1.16.200. The suggestions give above by A. Matulich and CalamityFred are essentially already part of how the game works, except that it is villages, not individual villagers, that keep track of claimed and unclaimed beds.
Based on CalamityFred's report that was resolved as a duplicate, his issue seems to have been cause by the game crashing when trying to tick the village chunks. That's really beyond the scope of this ticket.
Oh interesting, are you saying the long freezes experienced were actually crashes and there was some data loss? That might explain why some of the villagers vanished. I thought it was just a side effect of villages being only half-loaded.
I'd love to experiment some more to try and get villagers and beds to match again, we've just been spending more time outside because of summer.
If villagers vanished there was definitely data loss. I thought the long freezes implied you had to force-close the game. Even if you didn't something clearly was not working correctly in those chunks at that time. If the game couldn't load or update some of the villagers properly then the village may not have been able to count them.
Presumably for the issue to happen, the bed and villager count in the village is some kind of variable which is only updated when a bed is placed down, mined, or a villager added or removed? And when that happens the variable is incremented or decremented by one, it doesn't recount at any point.
At which point, if I still have one more villager than bed, there's one bed out there that isn't counted, I need to find it, mine it and replace it. It worked for the other 3.
I had this! (Nintendo Switch, both single player & realm).
I had a village (a failed iron farm) with 50 beds and 8 workstations (composters) but got HUNDREDS of villagers that just bred and bred and bred. They'all dead now.
Notice there are more than 8 farmers too.
[media]