mojira.dev
MCPE-85954

Villages in the nether or end are unstable

Villages in the end and nether are not saved correctly. As a result they get recreated with each relog and therefore the POI links are unstable. (The original report below focused on world corruption due to duplicate data village data being saved, but that could not be verified in-game. Players have also found that visiting the overworld coordinates matching a nether villager causes the duplicate village data to be cleared: see this comment.) Code analysis has been provided in this comment.

Steps to reproduce

  1. Place 2 beds and spawn 2 villagers in the end, then set time to night so that the villagers go to bed. Or use

[media]
  1. where this has already been done.

  2. Relog.

Expected result

Villagers continue to use the same bed they had linked to.

Actual result

The villagers re-link to the beds and sometimes do not link to the same bed they were sleeping in when you saved & quit. To reproduce this, it may help to open and close a different world before reopening the nether village world in step (2). See

[media]


Original report

How to reproduce:

  1. Put a bed and villager to create a village in the nether or end.

  2. Log out and look at the village file in universal Minecraft editor and make a note of the villager id number.

  3. Now log back into the game everything should seem normal.

  4. Log out and go back into universal Minecraft editor and look at the village data again.

Expected result:

Nothing should have changed and everything should be the same as the last time you checked.

Actual result:

There are now 2 villages both with 1 villager and 1 bed. The villager ID number is the same in both villages. Every time you rejoin the world a new village is created increasing your world size. These villagers arent ticked and are just ghost data. You can test this by looking at the ts timer in universal minecraft editor.

Extra info:

Villages in the end and nether can cause corrupted files.

This video explains it in more detail:
https://www.youtube.com/watch?v=jOJbuXctTWY&t=19s

This was the case until the 1.16.0.66 beta where it got worse. Like in before this the files still corrupt and when you remove the village in game it still creates a ghost village but if you dont remove the village it creates another ghost village every time you relog.

This video shows you the issue and how to reproduce this:
https://www.youtube.com/watch?v=jpKbooL43Ns 

Linked issues

Attachments

Comments 10

Sorry, but we cannot use repro steps that rely on a third party tool, because Mojang has no way to verify that the tool gives reliable results in all circumstances. And there's reason to doubt it: UME shows these so-called "corrupt data" entries and MCC Toolchest PE doesn't so at least one of them can't be relied on to tell us what we need to know in this case. We don't know which one that is, though, and it's also possible neither one is telling us.

Moreover, I believe Old Guy is jumping to conclusions about those UME tags being corruption. I have used UME for years and every world has always had them in varying quantities. Even a brand new flat world has them immediately after you create it. It's hard to make a case for corruption when there has been no crash and not even any blocks modified in the world. Old Guy probably thinks they're corruption because the way they're shown makes them look like NBT data with random binary data for keys, but they may not be NBT data at all, just an artifact of a bug in UME. That's why I say we can't use repro steps that require us to trust what UME tells us.

For what it's worth, I performed your repro steps and can verify that, according to UME, the village is recreated when you enter the Nether the second time and the same villager dwells in both copies at once. But unless this has a demonstrable negative effect on gameplay, it doesn't constitute a bug, it's just an oddity that might be an unintended inefficiency... or might simply be something intended whose purpose we don't understand. In either event, it's not a bug, so it's not the bug tracker's concern.

If you can revise your report to include a demonstrable gameplay impact and include steps that reproduce it, perhaps we can develop this into a proper bug report. Otherwise, the description does not fit the definition of a bug and we will have to close this report as Invalid.

Cleaning up old tickets: This ticket had been set to 'Awaiting Response', but has not received a response from the reporter (~3 months+) so is being closed as Incomplete. If you feel this is still a valid issue then please comment, or create a new ticket following the Issue Guidelines which includes steps to reproduce the problem.

Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki

here is what i will say on this matter, this is 100% busted, if you create a village in the nether or end it will work until it is unloaded, now ive confirmed this through third party tools which you dont consider valid, i get that, however upon reloading the village you can visibly see the village being recreated, ive made a few videos about this and the multiple copes of the village data that it produces,(once again the data was third party) however when reloaded the village no longer works as an iron farm or trading hall because the poi are scrambled because the village was recreated randomly upon loading it, now further testing not in my videos is that if you go to the exact coordinates in the overworld it clears this village copy data, so what is happening is that the game assumes all villages are in the overworld and then when you go to the overworld coordinates it realizes no village exists, however if you go back to the nether or end village it is recreated again,as many times as you load and unload it,  https://youtu.be/jOJbuXctTWY and  https://youtu.be/jpKbooL43Ns   i know that there are some third party software proofs in these videos but there are also some visual in game proof as well to show this is an actual problem in the game comment questions you can reach me on discord, hey 0ld guy
#8792

Code Analysis

Every Dimension has a VillageManager object which controls the creation and running of Villages. The End and Nether's VillagerManger works just like OverWorlds, which is why players can create Villages in the End and Nether.

However, when a village is saved (via VillageManager::saveAllVillages), the game does not record which dimension the village was in, and thus on restart the game has no way to know which VillagerManager object should load the village. Instead Dimension::init runs VillageManager::loadAllVillages only if the dimension is the Overworld. What this means is that loadAllVillages assigns every village in the world database to the Overworld.

The result is that on restart villages in the End and Nether no longer exist, but the game thinks there is a village in the same coordinates in the Overworld. If the player goes back to the village in the End and Nether, it will be recreated from scratch causing POIs to scramble and that sort of thing. Ever time the game is restarted and a new village is created, this causes additional village records to be added to the game save. The only way to clear these records is to visit the location of the village in the Overworld. Then the game will detect that the village no longer exists and then delete it.

Example

Create a Village at 100,100,100 in the End. Restart the game several times while staying in the End Village. Load up and inspect the save game with rbedrock (https://github.com/reedacartwright/rbedrock). You will see that there are multiple villages recorded as being located at 100,100,100. Restart the game again, and you will see an additional village recorded. Next visit 100,100,100 in the Overworld. Close the game and use rbedrock again. You will see that the extra villages will have disappeared.

Proposed Fix

(1) A VillageManager should know what dimension it is operating in and pass that on to any Village it creates.

(2) Village::_saveVillageData creates the "INFO" records for a village and it should save the dimension the Village is in.

(3) VillageManager::loadAllVillages should be run for every dimension and only load a Village if its INFO says it is from the correct dimension.

Alternatively, recall that village records are saved with a key like "VILLAGE_${VillageID}_${DataType}". E.g. "VILLAGE_ee966fd9-9b3c-421f-9312-d6f73b2ec77c_INFO". Instead of saving the dimension of the village as part of the village's INFO record, it can be saved as part of the key, e.g. "VILLAGE_${dimension}_${VillageID}_${DataType}", e.g. "VILLAGE_0_ee966fd9-9b3c-421f-9312-d6f73b2ec77c_INFO". That way a VillageManager object can load data that begins with with "VILLAGE_0_" or "VILLAGE_1_" or "VILLLAGE_2_" as appropriate. This also makes it easy to upgrade existing villages as the Overworld VillageManager can also read in and upgrade legacy Village records.

Affects 1.18.1
2 villagers (nether): Using the provided world file, I reloaded the world 10 times, each time checking the file size in File Explorer. The villagers apparently delinked, got out of their bed, relinked, & reentered the bed. The file size seems to have been negligibly affected, resulting in no obvious bloat. But both MCC Tool Chest & Universal Minecraft Editor confirmed that multiple villages had been created & not deleted. Each 2-villager-2-bed village contributes roughly 1,912 bytes to the world file, disregarding compression. A tag "Tick" contributes an additional 34 bytes.
In order to increase the world file size 1MB purely with this village, you'd have to reload the world 523 times (1 million/1,912).

12/100 villagers (overworld): For context, I loaded a 1.18 world with the seed "village" & flew to the nearest village, waited 3 minutes for villagers to link to POIs, & checked UME. The size of this rather small village of 12 villagers & 12 POIs (all 12 villagers had at least 1 POI, a bed) is 13.8KB. 72 reloads are necessary to bring the world size up by 1MB. I also set up a flat world with 100 villagers, 100 beds, 100 cartography tables, & 1 bell (it seems 5 cats spawned as well, but no iron golem). I was careful to kill all nitwits & babies & ensured each villager was linked to their workstation. I turned off dodaylightcycle & set the time to midnight so they would stay in their beds.
Copying the data to Notepad++, the size for the village alone came to 112,434 bytes. With only 9 reloads, the world should increase in size by 1MB.

100 villagers (nether): I made a similar setup in the nether, although this time grouping the villagers into pods of 6 beds each & an excess of cartography tables. Upon saving the world, the file size was 3.62MB. I confirmed with UME that there were 100 villagers & the village file size was 111,604 bytes (no cats spawned). Upon opening the world, all villagers left their beds & most of them failed to relink. Only 20 were able to sleep & it seems all of them were able to link to a random cartography table. I closed the world & its size in File Explorer was 2.37MB. I checked UME & the village file size was 111,560 bytes. The old village size remained unchanged.
I did this a 2nd time: I decided to leave the game open for a while to see if the villagers could delink & relink enough times to link to a bed in their pod. After about 2 hours, 81 were sleeping. 1.82MB world size, +111,218 bytes.
I reloaded the world more times, waiting at least 5 minutes before quitting. 3rd time: 2.75MB. 4th: 2.87MB. 5th: 2.74 MB. 6th: 3.33MB. 7th: 2.87MB. 8th: 2.78MB. 9th: 2.95MB. 10th: 2.93MB. 20th: 2.21MB. 21st: 1.40MB.
At this point I go to check the villager data. 1.40MB? That sounds like compression is definitely taking care of things. With 22 villages worth of data, the expected size for the villages alone is well over 2MB.

Conclusion: It seems the game's compression is good enough for most use cases in the short-term. Maybe someone else can take this to the extreme by reloading the world 100+ times, but the current bug report (villages get scrambled in dimensions other than the overworld) is definitely still valid. The old report (villages in nether or end corrupt worlds/bloat file size) has not been replicated with my testing. I invite others to contribute their testing where mine is lacking.

World with 100 villagers in nether has been added to the main report above.

Affects 1.19.2, villagers in the nether get unlinked from their beds whenever you save and quit in the overworld

Affects 1.19.70

 

I want to build a trading post in THE END.

It would require fixing the positions of villagers and  job site blocks, but I am unable to do so because of this bug.

If you don't understand what I mean, please comment. I will explain in more detail.

Like @HyperbolicSlime , this nerfed what of what I was trying to do, but I found the bug less troublesome if I did the following things:

  1. Only make a village of 13 workers

  2. Ensure that you only have ONE of each of the 13 professions

  3. Ensure that you only have ONE of each of the 13 job blocks

  4. Trade at least once with each of your 13 villagers

After doing that, the 13 villagers stay in their cells next to their block.  Nothing I can do to fix bed assignments moving, but that is less of an annoyance to me.  With this setup and 20 beds, I consistently get Iron Golems spawning after they get killed off by Endermen.

visual

(Unassigned)

494914

Confirmed

Multiple

end, nether, village

1.17.11 Hotfix, 1.14.30 Hotfix, 1.16.0, 1.16.10, 1.16.210, 1.16.221 Hotfix, 1.17.32, 1.19.0, 1.19.2 Hotfix, 1.19.20

1.20.40.21 Preview, 1.20.40

Retrieved