Page 1 of 1

Entity IDs inconsistent when re-exporting same blueprint

Posted: Thu Dec 04, 2025 3:35 am
by Plantagen
I'm trying to track my blueprints and update them as I make improvements (with version control such as git), but I've encountered a major problem: placing a blueprint and then exporting a blueprint based on that ghost, the entities inside it will have different ID numbers.

By decoding the blueprint, I see that the order of entities changes. (For example, use this website https://factorio-blueprint.vercel.app/decode-encode ) (No affiliation)

To reproduce this issue: make a blueprint, place it as a ghost somewhere else, then make a blueprint of the ghost, and the string will be different from the original one. Use absolute alignment 0,0 so that the coordinate position of individual items doesn't change depending on where you place it on the map.

Has anyone else had this problem and found a solution to it?

As an example, here are 2 different blueprint strings that I got from the game by pasting 1 blueprint in different locations, then exporting a blueprint from the ghost. The contents are the same: 1 wooden box and 1 fast inserter. But the ids are swapped in the two cases.

I can't guess why this would happen. If the game is to make a blueprint of identical items, why would it not assign them the same ID each time? Does it randomly choose which item to start with when making the blueprint?

1.

Code: Select all

0eNp1kN1qwzAMRt9F1/Zo0qbMfpUxhpNoqSCRg630h+B3n50VetH2SgjpHH1ohXZccA7EAnaFyG7W4vUQqC/9FWyl4Aa2TgpcG/24COqyNRMPYCUsqIA6zxHsV+ZpYDcWkt2EYOHifY+suxNGgewg7rFI07cCZCEh/Ce35vbDy9Ri2K7eDb8uiiaOGCQPFMw+ZsrzPd7uo9kC5pqSevLU6mWSt5qqaHI2Epwy9HiOgjOGuAHNsTYHY5rPam/M7pDSHxBhayQ=
Decodes to:

Code: Select all

{ "blueprint": { "snap-to-grid": { "x": 1, "y": 2 }, "absolute-snapping": true, "icons": [ { "signal": { "name": "wooden-chest" }, "index": 1 } ], "entities": [ { "entity_number": 1, "name": "fast-inserter", "position": { "x": 0.5, "y": 0.5 } }, { "entity_number": 2, "name": "wooden-chest", "position": { "x": 0.5, "y": 1.5 } } ], "item": "blueprint", "version": 562949958139904 } }

2.

Code: Select all

0eNp1kNFuwjAMRf/FzwlqOzqR/ApCU0q9Yql1qsTdQCj/TtJN8AA8Xtnn+MpX6MYF50AsYK8Q2c1avB4C9SWfwdYKLmCbpMB10Y+LoC5bM/EAVsKCCujoOYLdZ54GdmMh2U0IFn6975H18YRRIDuIeyzSdFCALCSEf+QaLl+8TB2G9eorg4LZxwx5/m9Xbdq1X71pU1JPmuau+XZRNHHEIHnw1lMVT+5GglOmHs9R8IMhrkD72ZitMe2u/jCm2qZ0Awa2ayQ=
Decodes to:

Code: Select all

{ "blueprint": { "snap-to-grid": { "x": 1, "y": 2 }, "absolute-snapping": true, "icons": [ { "signal": { "name": "wooden-chest" }, "index": 1 } ], "entities": [ { "entity_number": 1, "name": "wooden-chest", "position": { "x": 0.5, "y": 1.5 } }, { "entity_number": 2, "name": "fast-inserter", "position": { "x": 0.5, "y": 0.5 } } ], "item": "blueprint", "version": 562949958139904 } }

Re: Entity IDs inconsistent when re-exporting same blueprint

Posted: Thu Dec 04, 2025 3:41 am
by Rseding91
Indexes are assigned as entities are seen when iterating to save them to strings. The internal game representation is not in string form but full entities.

The entities in the blueprint are there in the order that they were found when iterating the area selected by the player making the blueprint.

There is no guarantee that placing and re-creating the blueprint will see the ghosts in the same order they were in the original blueprint. The orders are deterministic, but are not guaranteed to be any specific order.

Re: Entity IDs inconsistent when re-exporting same blueprint

Posted: Thu Dec 04, 2025 3:45 am
by Plantagen
Thanks for a quick reply.

I imagine I'm not the first person to try to track my blueprints like this. Does anyone have a solution?

I guess it would be possible to write a program that loops through the json, finds items and assigns new IDs based on their coordinate position (which will uniquely identify an item) and then swap all references to make it consistent.

Edit:
Yes, there is a tool doing exactly that.

https://github.com/nyurik/fatul

There is even a post on this forum about it

viewtopic.php?t=102874