Page 1 of 2

Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Fri Jan 15, 2021 11:00 am
by boskid
Introduction
Recently v453000 asked me about options to recover blueprints of a player that lost his blueprint library (viewtopic.php?p=530872#p530872). I looked at possible options and there were not many, however thinking a little more lead me to the simple conclusion: when blueprints from library are used in game, they are transferred so all the players have a copy of imported blueprint so it has to be part of a game state and be included inside of the save file. They are there and should be possible to be extracted. Only reason why they were not possible to be extracted was that when a player joins with an empty blueprint library, there is a blueprint library synchronization happening which removes all the blueprints that player does not have. From this a simple idea started to grow: if the synchronization would be bypassed (would not happen), it would be possible to get hands on the blueprints inside of a save file and take them out.
Limitations
This approach has some limitations. When player joins the game, synchronization is able to delete blueprints but it does not transfer new ones: it only creates a preview of a blueprint because blueprints contain entity data which can take a lot of space. Blueprints that are in the preview state are not part of the game state yet so they cannot be recovered using this approach.
The way
In the main menu, click "Settings" while holding both Ctrl and Alt. Modifiers are required to expose "The rest" part with all the hidden switches.
bprec-main-menu.png
bprec-main-menu.png (32.13 KiB) Viewed 20882 times
In settings go to "The rest"
bprec-settings.png
bprec-settings.png (81.6 KiB) Viewed 20882 times
Inside of the "Other settings" enable the "bypass-library-sync" option
bprec-bypass-on.png
bprec-bypass-on.png (2.88 KiB) Viewed 20882 times
Go back to the main menu and open a save file from which you want to extract blueprints.
bprec-load.png
bprec-load.png (6.26 KiB) Viewed 20882 times
While in game, open the blueprint library. There will be a warning "Blueprint library is not synchronized" to inform that the blueprint library here is not synchronized with player's own blueprint storage so none of the blueprints from player's blueprint storage are shown here. This also works in opposite direction: changes here will not get saved to the player's own blueprint storage.
bprec-library.png
bprec-library.png (90.39 KiB) Viewed 20882 times
From this point you can take a look at the blueprints and transfer them out. Simplest way is to empty the inventory, Control+Left click on empty slot in the library to transfer all blueprints to the inventory, create an empty blueprint book inside of the Game Blueprints, open that book, transfer all the blueprints from inventory to the book (Control+Left click on empty inventory slot) and then export that book to the string.

Alternative approach is to transfer blueprints to the inventory or to the Game Blueprints and save the game at that state. After disabling "bypass-library-sync" hidden option you can then load that save file and transfer those blueprints back to the "My Blueprints" which at this point will be synchronized (there should be no "Blueprint library is not synchronized" warning)

Cleanup: do not forget to disable "bypass-library-sync" option (first 3 steps).
Final notes
This way is intended to be only a last resort because it does not help with recovery of blueprints that were not transferred to the game state. Keep in mind that blueprint library uses binary format that is evolving with the game itself so older game versions are unable to read blueprint library made by newer versions. Every time you want to downgrade the game, the blueprint library will be lost (however there should be a backup made which may require manual file renaming to make backup to be the active one). When there are preview-only blueprints in the library, there may be some unintended behaviors happening when those blueprints are requested to be transferred: starting from importing a blueprint from the player's own blueprint library ending on the crashes because blueprint with the given ID does not exist in the player's own blueprint library.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Fri Jan 15, 2021 11:34 am
by Diablo
I just wanted to say here again, thank you so much for helping me out with this.
It means more then I can express here.

THANK YOU!

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Sat Jan 16, 2021 8:37 am
by ssilk
Would/should have been a nearly perfect FFF.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Sat Jan 16, 2021 8:46 am
by NotRexButCaesar
ssilk wrote: Sat Jan 16, 2021 8:37 am Would/should have been a nearly perfect FFF.
No gif means no FFF. (Devs are never sarcastic and always tell the 100% truth with no jokes)
talk on discord

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Tue Jan 19, 2021 4:00 pm
by quinor
That's the most factorio devs' thing I've seen in a long time. Come on, can you set the standarts any higher...?! Absolutely love the attention.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Thu Apr 01, 2021 11:01 pm
by Marco3104
This Post literally saved me many hours of work. Thank you very much!

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Sat May 08, 2021 4:24 pm
by mrfox113
Hello,

i tryd this, but after 5 bps into my inventory, the game crash.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Sun May 16, 2021 6:45 am
by ssilk
You can make a bug report, please.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Sun May 16, 2021 6:56 am
by boskid
mrfox113 wrote: Sat May 08, 2021 4:24 pm Hello,

i tryd this, but after 5 bps into my inventory, the game crash.
You are most likely trying to transfer a preview-only blueprint for which this method does not work. This was mentioned in the "limitations" part and in the "final notes" part. This is highly experimental "feature" and in case of a crash happening because of a misuse of it and following bug reports, i would rather remove this feature entirely rather than fixing it.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Fri Jun 04, 2021 3:36 pm
by MiniHerc
boskid wrote: Fri Jan 15, 2021 11:00 am Only reason why they were not possible to be extracted was that when a player joins with an empty blueprint library, there is a blueprint library synchronization happening which removes all the blueprints that player does not have.
But why remove them?

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Fri Jun 04, 2021 6:16 pm
by boskid
Ambaire wrote: Fri Jun 04, 2021 3:36 pm
boskid wrote: Fri Jan 15, 2021 11:00 am Only reason why they were not possible to be extracted was that when a player joins with an empty blueprint library, there is a blueprint library synchronization happening which removes all the blueprints that player does not have.
But why remove them?
Because player does not have them in local storage so they must have been removed intentionally.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Fri Jun 04, 2021 6:42 pm
by MiniHerc
boskid wrote: Fri Jun 04, 2021 6:16 pm
Ambaire wrote: Fri Jun 04, 2021 3:36 pm
boskid wrote: Fri Jan 15, 2021 11:00 am Only reason why they were not possible to be extracted was that when a player joins with an empty blueprint library, there is a blueprint library synchronization happening which removes all the blueprints that player does not have.
But why remove them?
Because player does not have them in local storage so they must have been removed intentionally.
Or the save was shared with another who would naturally not have those blueprints in local storage.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Sat Apr 23, 2022 3:17 pm
by Rescovedo
Recently bought a brand new Macbook Air and I honestly have no words to express so much gratitude towards this tutorial. REALLY REALLY Thanks, I was able to restore all my library back to what it was!

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Tue Apr 26, 2022 4:11 pm
by buddiedelorenzo
I don't understand why this method should be used only as a last resort? You said that it's a good method for restoring blueprints.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Sat Sep 17, 2022 9:01 pm
by aka13
I had the issue, where I accidentally put a bp book from hotbar into inventory, which removed it from the cloud bp storage.
Saved me a lot of trouble!

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Sun Oct 23, 2022 6:15 pm
by cheezecake
Just want to say thank you! This saved so much trouble and headache. Just used the export the book to string and it worked perfect.
I am putting a sticky note next to my PC that says "Do NOT downgrade Factorio unless absolutely necessary and back up all blueprints"

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Sun Feb 05, 2023 9:05 am
by Whalesaregreat
I created an account specifically to reply to this post to thank you. I spent nearly 4 hours today creating some rail and station blueprints, and I thought I had lost them after I accidentally removed them from my blueprint library and accidentally cleared them from my hot bar. Thank you so much.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Sat Feb 18, 2023 7:40 pm
by Dmytrozern
Still relevant. Downgraded my game to continue playing a save with active recording and lost my saves. Renaming the backup did not help, but this thread did. Thank you.

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Thu Apr 27, 2023 4:09 pm
by GriffiPlayz
Thanks! My blueprint library disappered after enabling steam cloud sync for blueprints (just like expected, that feature is a bit broken), and my blueprint backup i made a few days ago didn't want to work for some reason. (I tried copying the blueprint library file)
You saved my blueprints

Re: Last hope: blueprint library recovery from save file. (v1.1.9+)

Posted: Fri Sep 29, 2023 9:21 am
by flintycrayon
You, sir, are my hero.
Thank you <3