MineColonies

MineColonies

65M Downloads

NPC still forgets where the bed is

pwaksman973 opened this issue · 11 comments

commented

Is there an existing issue for this?

  • I have searched the existing issues.

Are you using the latest MineColonies Version?

  • I am running the latest beta/release version of MineColonies for my Minecraft version.
    I am also running the latest versions of other mods that are part of my problem.

Did you check on the Wiki? or ask on Discord?

  • I checked the MineColonies Wiki and made sure my issue is not covered there. Or I was sent from discord to open an issue here.

What were you playing at the time? Were you able to reproduce it in both settings?

  • Single Player
  • Multi Player

Minecraft Version

1.21

MineColonies Version

minecolonies-1.1.1143-1.21.1-snapshot

Structurize Version

structurize-1.0.787-1.21.1-snapshot

Related Mods and their Versions

No response

Current Behavior

Related to: #11194

NPC "Keaton D. Pericherla", with home location right in front of where I'm standing, is sleeping at the townhall.

Image

I saw other npc sleeping in some random location, then after while they run to the townhall and sleep in there, not in the townhall bed, I guess those are for decoration only. This session I was playing for like 4 ingame days before it started to not showing the all npc sleeping message.

Image

Even though they are assiged to a house and they were sleeping there the day prior.

Image

It also get fixed by just quit the game, and reloading.

Seems the same behavior as the previous bug from #11194, but instead of getting stuck at the residence hut, they go to the townhall after wandering around for while.

Expected Behavior

NPC would be able to find its free bed spot.

Reproduction Steps

no idea :( it just happens from time to time

Logs

https://gist.github.com/pwaksman973/e284fd65d5f57b4e84403fde25029fcb

Anything else?

No response

Footer


Viewers

  • Add a 👍 reaction to the bug report if you are also affected. This helps the bug report become more visible without cluttering the comments.
  • ⚠️ Only add a comment if you have new insights or background information not already mentioned. Off-topic or "+1" comments will be deleted to keep the discussion focused.
commented

I cannot reproduce this at all, even with an acacia colony. Can you send us your world?

commented

I think that citizen sitting in the townhall isn't sleeping as there is no green zZzzZz they might be stuck sitting there just from idling in the townhall before (would be a different problem)

commented

He is definitely not stuck there, well he was not stuck there, I followed him from middle of noware to the townhall, then hi sat there.
yah he have the blue zZz, like when they are going to bed, not the green when they are on bed

It is very random, like after I reloaded, it didn't happened again, and I played for a while now.

I can send the world, is quite huge instace though, but the problem won't be there as it fix on reload, so would be just open and wait.

Its most acacia buildins, but his house is nordic sprouce

commented
commented

run /mc colony export
to get a smaller zip that you can send

commented

Just added another video with a path debug of the bugged npc, it has all paths dots as red when recall in the residence hut.
The other npc that was sleeping there has no problem going back to bed.

I was going to also debug the path of the working npc, but with my luck, a guard died and that exact npc became a guard :( .

I hope it helps in anyway. Let me know if you have anything for me to try or run.

At the end he went to the townhall just like the other npc before, but first he went to the tavern for whatever reason.
Next day he did went to sleep just fine, without even reloading the game

commented

Right,

https://drive.google.com/drive/folders/1RV6UcvkAURf1mGWqGBgFXIy3_SDd8dHR

Have 3 files with the whole instance, separated in all other files, the save, and the mods. This is the instance folder that FTB App uses.
Then also the colony export.

Just teleport to -8548 70 1329, and you will be right in the middle of the colony. Colony ID 1, there is only this colony

If you have a particular class that you want to check something I could compile and run here witth some extra logs.
I was going to do that but I got lost as hell in the code so I didn't try. But if you have an specific point in mind already, just let me know.

commented

I also added a recording of the thing happening, the .mkv file

commented

I got some progress on this, not sure if it is the actual cause of the NPC sleeping anywhere, since in this case the NPC did went home but couldn't get in bed, might be a diferent issue here.

There are two things happening:

1º The findBed() function is already timed out whe it first run, so it skip the call on findBedAndTryToSleep(). Then it run sleep() which will then run findBedAndTryToSleep().

2º The residence building was lvl 2, got updated to lvl 3, bed count was 2, now should be 3, but the size of the list on this function return 5.

EntityAISleep
   ...
   findBedAndTryToSleep()
     ...
      if (usedBed == null || usedBed == homePos)
          final List<BlockPos> bedList = hut.getModule(BuildingModules.BED).getRegisteredBlocks();

This will enter the first if check, and skip the first validation about "state not bed", and enter the second validation and set the usedBed = pos, which probably is one of the 2 extra bed that shouldn't exist.

Next cycle it will run sleep() again, it will call walkHome()
walkHome will fail the first if, and enter on the second one homeBuilding.isInBuilding(citizen.blockPosition()), setting it to FIND_BED.
finally it calls findBed(), but bedTick was never reseted so it just skip the call on findBedAndTryToSleep

Then it will loop into those functions
sleep() that sets to FIND_BED
findBed() skips becasue it is timeoude.
sleep calls walkHome, walkHome will set to FIND_BED, findBed just skips, sleep runs again

History actions in sequence:

Day prior to the building, the npc was failing to sleep already, but with a valid reason.
The building was middle way trough construction, and the bed was literally burried below dirt, so the findBedAndTryToSleep was always failing since the bed was considered occupied.

Next day, the building got finished, but the npc got stuck again.
It first got the initAI() when like 40 blocks away
it kept alternating between goHome() and walkHome() while the npc moves, until it finally pass the check homeBuilding.isInBuilding(citizen.blockPosition()), which change it to FIND_BED.

And from here it get stuck.

I'm still looking for the case where the NPC is set to sleep but it is just walking around.

commented

Once reloading the game, the bedCount still 5, it call findBed(), findBedAndTryToSleep(), and reset the bedTick a couple of times and the trySleep(usedBed) works and the npc go to sleep.
So the 5 bed count doesn't seem to cause an issue

commented

this stil happens on the latest: minecolonies-1.1.1146-1.21.1-snapshot

Image